Sie sind auf Seite 1von 3

%% EED364 : Graph Signal Processing |[Lab-4]|

% * Author: Sagar Verma


% * Roll no:1410110344
% * Email id:sv185@snu.edu.in
% * Lab batch: 2-4
% * Lab Instructor: _Prof.Vijay Kumar Chakka_

%% Objective:Convolution Property of GFT


clc
clear all;
close all;
[B,XY]=bucky;
B=full(B);
Input1=load('inputSignal.mat');
Input1=Input1.inputSignal;
Input2=load('inputSignal.mat');
Input2=Input2.inputSignal;
degree=sum(B,2);
degree=diag(degree);
L=degree-B;
[U,D]=eigen(L);
h1=[0.5,0.5];
h1=[h1 zeros(length(B)-length(h1),1)']';
h2=[0.5,-0.5];
h2=[h2 zeros(length(B)-length(h2),1)']';
h3(1:length(B))=0.5;
h3=h3';
for j=1:length(B)
if(mod(j,2)==1)
h4(j,1)=0.5;
else
h4(j,1)=-0.5;
end
end
%% finding gft coefficients
H1=U'*h1;
H2=U'*h2;
H3=U'*h3;
H4=U'*h4;
X1=U'*Input1;
X2=U'*Input2;
%% finding output gfts
Y1X1=H1.*X1;
Y2X1=H2.*X1;
Y3X1=H3.*X1;
Y4X1=H4.*X1;
Y1X2=H1.*X2;
Y2X2=H2.*X2;
Y3X2=H3.*X2;
Y4X2=H4.*X2;

%% finding inverse gft output


y1X1=U*Y1X1;
y2X1=U*Y2X1;
y3X1=U*Y3X1;
y4X1=U*Y4X1;
y1X2=U*Y1X2;
y2X2=U*Y2X2;
y3X2=U*Y3X2;
y4X2=U*Y4X2;

%% gsignal plot
figure(2);
subplot(2,3,1);
Gsignalplot(B,XY,y1X1');
subplot(2,3,3);
Gsignalplot(B,XY,y1X1');
subplot(2,3,4);
Gsignalplot(B,XY,y1X1');
subplot(2,3,5);
Gsignalplot(B,XY,y1X1');
%% Filtering (high variation signal is the eigen vector corresponding to
highest eigen value)
figure(3);
subplot(2,1,1);
Gsignalplot(B,XY,U(:,length(U))');
%% zero variation signal is the eigen vector corresponding to zero eigen
value
subplot(2,1,2);
Gsignalplot(B,XY,U(:,1)');
%% low pass filter that allow first three variations
LPF1=[1,1,1];
LPF=[LPF1 zeros(1,length(U)-length(LPF1))]';
lpf=U*LPF;
figure(4);
subplot(2,2,1);
Gsignalplot(B,XY,lpf');
YLX1=X1.*LPF;
ylx1=U*YLX1;
subplot(2,2,2);
Gsignalplot(B,XY,ylx1');
YLX2=X2.*LPF;
ylx2=U*YLX2;
subplot(2,2,3);
Gsignalplot(B,XY,ylx2');
%% High pass filter allowing the last 5 variation signals
HPF1=[1,1,1,1,1];
HPF=[zeros(1,length(B)-length(HPF1)) HPF1]';
hpf=U*HPF;
figure(5);
subplot(2,2,1);
Gsignalplot(B,XY,hpf');
YHX1=X1.*HPF;
yhx1=U*YHX1;
subplot(2,2,2);
Gsignalplot(B,XY,yhx1');
YHX2=X2.*HPF;
yhx2=U*YHX2;
subplot(2,2,3);
Gsignalplot(B,XY,yhx2');
%% bandpass filter for the middile variated
BPF=[zeros(1,length(U)/2-1) 1,1 zeros(1,length(U)/2-1)]';
bpf=U*BPF;
figure(6);
subplot(2,2,1);
Gsignalplot(B,XY,bpf');
YBX1=X1.*BPF;
ybx1=U*YBX1;
subplot(2,2,2);
Gsignalplot(B,XY,ybx1');
YBX2=X2.*BPF;
ybx2=U*YBX2;
subplot(2,2,3);
Gsignalplot(B,XY,ybx2');

function [ X ] = D2plot( A ,X)

plot(X(:,1),X(:,2),'*');
for i=2:length(A)
for j=1:i-1
if A(i,j)>0
line([X(i,1),X(j,1)],[X(i,2),X(j,2)]); %plotting the lines
between the coordinates
%text((X(i,1)+X(j,1))/2,(X(i,2)+X(j,2))/2,num2str(A(i,j)));
end
end
end

end

function [ U,D ] = eigen( A )


[U,D]=eig(A); % finding eigen values and vectors
D=diag(D);
D=D';
D=round(D,5); %rounding off to 10 power to -5
U=[U;D];
U=sort(U,length(A)+1); % sorting with respect to eigen values
U=U(1:length(A),1:length(A));
U=round(U,5);
D=sort(D);
D=D';
end

Das könnte Ihnen auch gefallen