%% Example: The SVD clear close all; %This closes all open figures load mandrill; %This loads an "image" in the matrix X, colors are in "map" fprintf('The original matrix as an image\n'); figure(1) image(X) colormap(map) %% Now perform the SVD [U,S,V]=svd(X); %% Look at partial reconstructions of the matrix using the following number of basis vectors NumVecs=[3,6,10,50,150,480]; for k=1:6 j=NumVecs(k); H=round(U(:,1:j)*S(1:j,1:j)*V(:,1:j)'); figure(2) subplot(2,3,k) image(H) colormap(map) end