% lec11script.m code snippets used in class on 15 June
% Download randhbdemo.m too.
% In randhbdemo.m, set noise to zero for first demonstation and
% then to 0.05 for second one. 
% You might also play around with changing the number of "pixels" in
% the image. 


%For Monday, 15 June, Lec 11.

clear;close all;randhbdemo;
figure;imagesc(w,w,log10(cov(mu')));axis image;colorbar;

% Eigenvector problem
[S,D]=eigs(cov(mu'));
figure;plot(w,S(:,1:5));grid on;title('Eigenvectors');
figure;semilogy(1:size(D,1),diag(D),'-o');grid on;title('Eigenvalues');

% Singular value decomposition
[U,S,V] = svd(cov(mu'));
figure;semilogy(1:size(S,1),diag(S),'-o');grid on;
title('Singular Values');
figure;plot(w,U(:,1:5));grid on;title('Singular Vectors');

[W,H]=nnmf(mu',10);
figure;imagesc(w,1:5,H(1:5,:));colorbar;title('nnmf Vectors');
figure;imagesc(W);colorbar;title('nnmf Image');
figure;plot(w,H(1:5,:));grid on;title('nnmf Vectors');
