matlab - Implementing matching pursuit algorithm -


i have implemented matching pursuit algorithm m unable required result.

here code:

d=[1 6 11 16 21 26 31 36 41 46     2 7 12 17 22 27 32 37 42 47     3 8 13 18 23 28 33 38 43 48     4 9 14 19 24 29 34 39 44 49     5 10 15 20 25 30 35 40 45 50]; b=[6;7;8;9;10]; n=size(d); a1=zeros(n); r=b; h=10; if(h <= 0)     error('the number of iterations needs greater 0') end; k=1:1:h     [c,d] = max(abs(d'*r));    %//'     a1(:,d)=d(:,d);     d(:,d)=0;     y = a1\b;     r = b-a1*y; end 

output

y=  0.8889        0        0        0        0        0        0        0        0   0.1111  

i should non-zero value @ (2,1) , other values should 0 i'm getting 2 non-zero value. can please me find out error is?

thanks.

i checked with: http://www.scholarpedia.org/article/matching_pursuit

your functions need normalized!

d = d./repmat(sum(d,1),5,1); 

i following algorithm:

d=[1 6 11 16 21 26 31 36 41 46     2 7 12 17 22 27 32 37 42 47     3 8 13 18 23 28 33 38 43 48     4 9 14 19 24 29 34 39 44 49     5 10 15 20 25 30 35 40 45 50]; d = d./repmat(sum(d,1),5,1); b=[6;7;8;9;10]; n=size(d); a1=zeros(n); r=b; h=100; if(h <= 0)     error('the number of iterations needs greater 0') end; = zeros(1,h); g = zeros(size(d,1),h); k=1:1:h     ip = d'*r;     [~,d] = max(abs(ip));    %//'     g(:,k) = d(:,d);     a(k) = ip(d);     r = r-a(k)*g(:,k); end  % recover signal: rrec = zeros(size(r)); i=1:h     rrec = rrec + a(i)*g(:,i); end figure(); plot(b); hold on; plot(rrec) 

it approximates signal quite well. not d(:,2) @ first expected. maybe starting point...


Comments