-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathoperator_example.m
38 lines (29 loc) · 1.28 KB
/
operator_example.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
% Matlab script for solving the sparse signal recovery problem
% using the object-oriented programming feature of Matlab.
% The three m files in ./@partialDCT/ implement the partial DCT class
% with the multiplication and transpose operators overloaded.
rand('state',0);randn('state',0); %initialize (for reproducibility)
n = 1024; % signal dimension
m = 128; % number of measurements
J = randperm(n); J = J(1:m); % m randomly chosen indices
% generate the m*n partial DCT matrix whose m rows are
% the rows of the n*n DCT matrix at the indices specified by J
% see files at @partialDCT/
A = partialDCT(n,m,J); % A
At = A'; % transpose of A
% spiky signal generation
T = 10; % number of spikes
x0 = zeros(n,1);
q = randperm(n);
x0(q(1:T)) = sign(randn(T,1));
% noisy observations
sigma = 0.01; % noise standard deviation
y = A*x0 + sigma*randn(m,1);
lambda = 0.01; % regularization parameter
rel_tol = 0.01; % relative target duality gap
%run the l1-regularized least squares solver
[x,status]=l1_ls(A,At,m,n,y,lambda,rel_tol);
figure(1)
subplot(2,1,1); bar(x0); ylim([-1.1 1.1]); title('original signal x0');
subplot(2,1,2); bar(x); ylim([-1.1 1.1]); title('reconstructed signal x');
%print -deps fig_operator_example.eps