% Read in the image build a symmetric image load clown figure(1) image(X) colormap(map) axis square X=X'; %Force it to be purely symmetric A=zeros(200,200); for j=1:200 temp=X(j:200,j); A(j:end,j)=temp; A(j,j:end)=temp'; end figure(2) image(A) colormap(map) axis square %Find the eigenvalues (in matrix D) and eigenvecs (in V). [V,D]=eig(A); %Plot the spectral decomposition, ordered by the magnitude of the %eigenvalues: t=diag(D); [val,idx]=sort(abs(t),'descend'); figure(3) image(A) colormap(map) axis square for j=1:60 H=V(:,idx(1:j))*diag(t(idx(1:j)))*V(:,idx(1:j))'; image(round(H)) Err(j)=norm(H-A,'fro'); pause(0.1) end