# How can you change the Compressed Sensing transform such that CVX will solve appropriately?

Hi all! Thank you endlessly for your support from my last question.

I’ve been using sample code from Steve Brunton’s introduction to compressed sensing (https://databookuw.com/databook.pdf , ch.3), and I am trying to change the type of transform that I use on a 2 dimensional signal before reconstructing it. When I do so, CVX will sometimes produce data that is more off than I believe it should be. So, I’m seeking help on either of these points:

1. How can I change the signal x to be any random signal instead of a sum of cosines?
2. Why does changing the transform to FFT or dwt2 cause CVX errors? How can I avoid these?

**Code **
% build original signal
m = 400; % length
t = linspace(0,1,m);
x = cos(2pi97t) + cos(2pi97t);
plot(x)

% Randomly sample signal
p = 100; % sparsity
perm = round(rand(p, 1) * m);
y = x(perm); % compressed measurement

% Solve compressed sensing problem
Psi = dct(eye(m, m)); % change here
Theta = Psi(perm, :);

% L1-Minimization using CVX
cvx_begin;
variable s(m);
minimize( norm(s,1) );
subject to
Theta*s == y’ ;
cvx_end;
xrecon = idct(s);

You haven’t told us what kind or errors are occurring in CVX. Based on the program, the only “errors” which seem possible are if the problem is declared infeasible or numerical difficulties are encountered by the solver.

As to whether this optimization model is appropriate (good) for your intended application, that is for you to determine, and not really a CVX matter. You should not assume that people answering questions on this forum are compressed sensing experts.