-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo1.m
65 lines (52 loc) · 2.3 KB
/
demo1.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
%% demo1: Enhanced Low-Rank Matrix Approximation (ELMA)
%
% Reference: Enhanced Low-Rank Matrix Approximation
% A. Parekh and I. W. Selesnick
% IEEE Signal Processing Letters, 2016.
%
% Note, for better results use the 'atan' penalty.
%
% Last Edit: 2/21/2016
% Ankit Parekh, NYU Tandon
%% Function definitions
% Initialize
clear
% soft-threshold function
soft = @(x,lam) max(1 - lam./abs(x), 0) .* x;
% firm-threshold function
firm = @(x,lam,a) min(abs(x), max((abs(x)-lam)./(1-a.*lam),0)).* sign(x);
%% Generate random matrix
% Matrix M = A*B has rank 'r' and is of size 'm by n'.
% A is of size 'm by r' and B is of size 'r by n'.
m = 200;
n = 100;
r = 10;
sigma = 6; % Noise level sigma
A = randn(m, r);
B = randn(r, n);
M = A * B;
Y = M + sigma * randn(m, n); % Add AWGN to the clean matrix M
%% Estimate the Low-Rank Matrix using ELMA and NNM
[U,S,V] = svd(Y); % SVD of the input matrix Y
% Enhanced low-rank matrix approximation (ELMA) method
ELMA.lam = 22.7*sigma; % Parameters for ELMA method
ELMA.a = 0.99/ELMA.lam;
ELMA.S = thresh(S, ELMA.lam, ELMA.a,'atan'); % ELMA Approximated singular value matrix
ELMA.X = U * ELMA.S * V'; % ELMA Low-Rank Approximation
% Nuclear norm minimization (NNM) method
NNM.lam = 22*sigma; % NNM parameters
NNM.S = soft(S, NNM.lam); % NNM Approximated singular value matrix
NNM.X = U * NNM.S * V'; % NNM Low-Rank Approximation
%% Plot the singular values of the approximated matrices
figure(1), clf
plot(1:n, diag(S),... % Noisy singular values
1:n, svd(M),... % Original singular values
1:n, diag(ELMA.S),... % ELMA approximated singular values
1:n, diag(NNM.S)) % NNM approximated singular values
xlabel('n')
ylabel('n-th singular value')
legend('Noisy singular values','True singular values',...
'ELMA','Nuclear norm minimization (NNM)')
xlim([1 30])
print -dpdf demo1