load -ascii omasvd.mat
svdmat=omasvd;

stri(1,:)='Schumacher ';
stri(2,:)='rata       ';
stri(3,:)='formula    ';
stri(4,:)='kolari     ';
stri(5,:)='galaksi    ';
stri(6,:)='tähti      ';
stri(7,:)='planeetta  ';
stri(8,:)='meteoriitti';

[u,s,v]=svd(svdmat);

% Reduce reconstruction dimensionality
u_red=u(:,1:2);
s_red=s(1:2,1:2);
v_red=v(:,1:2);

% Reconstruction
recon=u_red*s_red*v_red';

% Similarities
b=s_red*v_red';
temp=sqrt(sum(b.*b));
e = b./[temp;temp];
correla=e'*e;

%Original distaces
temp=sqrt(sum(svdmat.*svdmat));
svd_norm=svdmat./repmat(temp,size(svdmat,1),1);
