Large measurements b matrix

In your “full PHI matrix” code, Ax is m by 1, and b is my by p, so the dimensions don’t match to form Ax-b, hence MATLAB provides an error message. Your second code may be taking a long time because it incurs CVX overhead each time through the loop. Does each column of PHI correspond to a separate optimization problem, independent of the problems for other columns? If not, your second code is wrong. If the problems are independent, how about

cvx_begin
variable x(n,p)
expression Objective(p)
for k=1:p
Objective(k) = norm(A*x(:,k)-PHI(:,k)) + gamma * norm(x(:,k),2); 
end
minimize(sum(Objective))   
cvx_end

I have stacked p independent optimization problems on top of each other by summing the objectives, and I believe that the result will be that the solver will provide a solution to all at once, equivalent to if they had been presented as separate problems. So after CVX finishes, x(:,k) for k=1:p should contain the optimal x for the problem corresponding to the kth column of PHI.

This way, you should only incur the overhead of CVX once. I’ll leave any vectorization of the above as an exercise for you.

Edit: This edit serves only to bump the thread so that my comment below from Dec 22 will be evident.