-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_singular_values.m
More file actions
21 lines (20 loc) · 893 Bytes
/
plot_singular_values.m
File metadata and controls
21 lines (20 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function plot_singular_values(singular_values)
%PLOT_SINGULAR_VALUES Plotting magnitudes of singular values and retained energy
% Given a vector S containing singular values in decreasing order, this
% function plots two graphs indicating:
% - magnitudes of singular values vs indices of singular values;
% - ritained energy as the number of singular values increases, starting
% with the highest indeces.
figure;
subplot(1, 2, 1);
bar( singular_values(end:-1:1), 'red');
xlabel('SINGULAR VALUES FROM SMALLEST TO LARGEST');
ylabel('MAGNITUDES OF SINGULAR VALUES');
subplot(1, 2, 2);
plot( cumsum( singular_values.^2 ) / sum( singular_values.^2 ), 'LineWidth', 2);
grid on;
xlabel('SINGULAR VALUES FROM LARGEST TO SMALLEST');
ylabel('RETAINED ENERGY');
pos = get(gcf, 'Position');
set(gcf, 'Position',pos+[-1000 -1000 1000 1000]);
end