     function mess = SVDword(word)
% computes approximations of a "word" via partial dyadic SVD sums     
     
[u,s,v] = svd(word); [n,m] = size(word); mess = zeros(n,m); d = diag(s);
spy(word), title(['The full word'],'FontSize',12), pause  % pauses with each plot

for k = 1:min(n,m) % create rank k best approxiamtions to the pixel matrix "word"
  format short, fprintf('k = %g \n \n',k),               % on screen running rank
  mess = mess + d(k) * u(:,k) * v(:,k)'; messk = mess;
  for i = 1:n
    for j = 1:m
      if abs(messk(i,j)) < 0.5
         messk(i,j) = 0; end; end; end
    spy(messk),                                          % visual output
    title(['The reconstructed word at stage k = ',num2str(k)],'FontSize',12)
    pause, end 
