How to implement compressed sensing reconstruction?
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.