I am new to the field of Compressive Sensing. I'm trying to implement an example in this link. This example have described and implemented a sample tone reconstruction carefully, but unfortunately, there is no use of
l1-magic toolbox to reconstruct the signal using compressive sensing minimization.
I know that
l1eq_pd function in
l1-magic calculates x in Ax=b for compressed sensing but when I use this function it returns an error
Error using linsolve: Matrix must be positive definite.
Have anyone solved this minimization before?
Does anyone know any substitute for this toolbox?
How can I format my code in stack exchange (below code) for Matlab using
<!-- language: lang-or-tag-here --> ?
My Matlab code:
%% signal initialization n = 1/40000:1/40000:1/8; f = sin(1394*pi*n) + sin(3266*pi*n); %% Random Sampling % b = Phi * f (random sampling) % c = Psi * f where Psi = IDCT (sparsifying) m = floor(rand(1,500)*length(f)); b = f(m); % random samples of (f) c = idct(f); % sparsed (f) plot(f,'b');hold plot(m,b,'k.');title('Original Signal(f) and random sampless(b)'); axis([1,1000,-3,3]) legend('Original Signal','Randomly Sampled Signal') figure, plot(c), axis([0,650,-10,10]);title('Sparse samples (c = IDCT(f))'); % f = Psi * c % Psi = DCT % f = DCT(c) % c = IDCT(f) %% solution 1 (x) % Ax = b % x = A\b D = dct(eye(length(n),length(n))); A = D(m,:); % sound(f) x = (A\b')'; b_hat = dct(x); % sound(b_hat) %% solution 2 (y) % Ay = b % y = pinv(A) * b y = (pinv(A)*b')'; figure,plot(y),axis([0,650,-10,10]) figure,plot(dct(y)),axis([1,1000,-1.5,1.5]) %% solution 3 (s1) s1 = l1eq_pd(y',A,A',b',5e-3,20); % L1-magic toolbox
This piece of code is a good example to understand compressed sensing and works correctly except the last line I am questioning.