-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdemo10.m
57 lines (39 loc) · 976 Bytes
/
demo10.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
clear all
close all
clc
% load predefined W matrix for 100 nodes
load mydata
% calculate combinatorial Laplacian Matrix
d = sum(W,2);
L = diag(d)-W;
% calculate Laplacian Matrix
% find eigenvector and eigenvalues of combinatorial Laplacian
[u v]=eig(L);
% make eignevalue as vector
v=diag(v);
% get maximum eigenvalue
lmax=max(v);
v(v<0)=0;
% create signal where first node is 1 rest of them zero
s=zeros(size(W,1),1);
s(1)=1;
% determine filter
flt =exp(-20*v);
% apply that filter on to graph signal
sf=u*(flt.*(u'*s));
% filter over new eigenvalue basis
K=50;
nv=linspace(0,8,K)';
basis=bspline_basis(K, nv,v, 3);
alpha=exp(-20*nv);
flt=basis*alpha;
% apply that filter on to graph signal
sf2=u*diag(flt)*u'*s;
figure;plot(sf,'b--','linewidth',2)
hold on;plot(sf2,'r-')
xlabel('node id')
ylabel('node signal value')
legend({'original basis','spline basis'})
G=gsp_graph(WW,coord2);
figure;gsp_plot_signal(G,sf2)
title('Filtered signal on second graph');