a = [1,1,1;2,3,4]'
b = [1,0,1;0,1,1]
c = a*b;
[u,s,v] = svd(c)
c
u*s*v'

a = rand(10,4)*rand(4,10)
[u,s,v] = svd(a);
diag(s)
vt = v';
a - u*s*vt
a - u(:,1:4)*s(1:4,1:4)*vt(1:4,:)

I = imread('../dog1.jpg');
Ibw = rgb2gray(I);
J = imresize(Ibw(100:300,100:300),.3);
[ud,sd,vd] = svd(double(J));
figure; colormap(gray); k=10;vdt = vd';  imagesc(ud(:,1:k)*sd(1:k,1:k)*vdt(1:k,:));title(['dog with num. components = ', int2str(k)]);