26 lines
410 B
Matlab
26 lines
410 B
Matlab
function flg = can_recovery(Psi, s, eps)
|
|
[m, n] = size(Psi);
|
|
|
|
x = zeros(n, 1);
|
|
random_indices = randperm(n, s);
|
|
x(random_indices) = randn(s, 1);
|
|
x = sign(x);
|
|
y = Psi * x;
|
|
|
|
cvx_begin
|
|
variable s1(n)
|
|
minimize(norm(s1, 1))
|
|
subject to
|
|
norm(y - Psi * s1) <= eps
|
|
cvx_end
|
|
|
|
p = norm(x - s1, 2);
|
|
|
|
if p < eps
|
|
flg = 1;
|
|
else
|
|
flg = 0;
|
|
end
|
|
|
|
end
|