
A = [0 0 0 0 0 0 0 0 0;
     0 1 1 0 0 0 0 0 0;
     0 1 1 0 0 0 0 0 0;
     0 0 0 1 1 1 1 0 0;
     0 0 0 1 1 1 1 0 0;
     0 0 0 1 0 0 1 0 0];


figure(1)
showimage(A)


rankA = rank(A)
junk = input('Hit return for low rank approximations');

[U,S,V] = svd(A)

figure(2)
for k=1:rankA
    Ak = U(:,1:k) * S(1:k,1:k) * V(:,1:k)';
    showimage(Ak)
    junk = input('Hit return to continue...');
end
