0
$\begingroup$

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 --> ?


Appendix 1:

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.

$\endgroup$
  • $\begingroup$ I do not get it, in which part of your code you're using l1magic? $\endgroup$ – MimSaad May 16 '17 at 16:08
  • $\begingroup$ @MimSaad in the last line which I commented L1-magic $\endgroup$ – M.Jalali May 17 '17 at 6:05
  • $\begingroup$ My bad!, now I guess my answer would help you. $\endgroup$ – MimSaad May 17 '17 at 17:13
1
$\begingroup$

I have had encountered this problem before. In using l1-magic toolbox, the first thing you need to do is to modify the file l1eq_pd.m.

To do so find all linsolve instructions and remove the third parameter, for example on line 141 change the following line from

[dv,hcond] = linsolve(H11p, w1p,opts);

to,

[dv,hcond] = linsolve(H11p, w1p);

This is because the structure opts specify the property of the matrix A in solving Ax=b linear system of equations and omitting the structure opts in the linsolve function will allow Matlab to choose the appropriate solver automatically [Reference]

If the errors persists, your own code should be scrutinized.

I suggest to have a look on this examples codes.

$\endgroup$
  • $\begingroup$ There is a problem using those arguments, Not enough input arguments. $\endgroup$ – M.Jalali May 18 '17 at 6:57
  • $\begingroup$ same error as my code above happens in the example you suggested $\endgroup$ – M.Jalali May 18 '17 at 7:01
  • 1
    $\begingroup$ it is because the l1eq_pd.m still is unmodified $\endgroup$ – MimSaad Feb 8 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.