Candes.m
From Wikimization
(Difference between revisions)
(New page: <pre> %Emmanuel Candes, California Institute of Technology, June 6, 2007 %IMA Summerschool n = 512; % Size of the signal m = 64; % ...) |
|||
| Line 17: | Line 17: | ||
b = A*x0; | b = A*x0; | ||
| - | %% Solve | + | %% Solve l1 using CVX |
cvx_begin | cvx_begin | ||
variable x(n); | variable x(n); | ||
| Line 27: | Line 27: | ||
figure, plot(1:n,x0,'b*',1:n,x,'ro'), legend('original','decoded') | figure, plot(1:n,x0,'b*',1:n,x,'ro'), legend('original','decoded') | ||
</pre> | </pre> | ||
| + | |||
| + | [http://www.stanford.edu/~boyd/cvx CVX] | ||
Revision as of 17:22, 1 July 2008
%Emmanuel Candes, California Institute of Technology, June 6, 2007
%IMA Summerschool
n = 512; % Size of the signal
m = 64; % Number of samples (undersample by a factor 8)
k = 0:n-1; t = 0:n-1;
F = exp(-i*2*pi*k'*t/n)/sqrt(n); % Fourier matrix
freq = randsample(n,m);
A = [real(F(freq,:));
imag(F(freq,:))]; % Incomplete Fourier matrix
S = 28;
support = randsample(n,S);
x0 = zeros(n,1); x0(support) = randn(S,1);
b = A*x0;
%% Solve l1 using CVX
cvx_begin
variable x(n);
minimize(norm(x,1));
A*x == b;
cvx_end
norm(x - x0)/norm(x0)
figure, plot(1:n,x0,'b*',1:n,x,'ro'), legend('original','decoded')