%SVDSHOW animated display about the svd of the 2-by-2 matrix A.
% If the 2-by-2 matrix  A  is not defined, you will be prompted for it.

% from Cleve Moler jul95, somewhat adapted by cb
% latest change: 17oct97

clf reset
if ~exist('A'), A = input('Enter A: '); end
t = -pi:pi/50:pi;
plot(cos(t),sin(t),'b')
s = max(1,norm(A));
axis([-s s -s s])
axis square
title(sprintf('A = [ %6.3f  %6.3f; %6.3f  %6.3f ]',A'))
xlabel(['Move x, y (blue) to make Ax, Ay (red) perpendicular. ',...
        'Also shown: A''Ax, A''Ay.'])
h(1) = line([1 0 0],[0 0 1],'erase','xor','color','b','linew',2);
h(2) = line([0 0],[0 0],'linestyle','.','erase','none','color','r', ...
            'Markersize',12);
h(3) = line([A(1,1) 0 A(1,2)],[A(2,1) 0 A(2,2)],'erase','xor',...
             'color','r','linew',2);
h(4) = line([0 0],[0 0],'linestyle','.','erase','none','color','c', ...
            'markersize',12);
h(5) = line([A(1,1) 0 A(1,2)],[A(2,1) 0 A(2,2)],'erase','xor','color','c');
set(gcf,'windowbuttondownfcn', ...
  'svdshowf(h,A); set(gcf,''windowbuttonmotionfcn'',''svdshowf(h,A)'')')
set(gcf,'windowbuttonupfcn', ...
     'set(gcf,''windowbuttonmotionfcn'','''')')
%set(gcf,'windowbuttonupfcn', ...
%    ['title(sprintf(''A = [ %6.3f  %6.3f; %6.3f  %6.3f ]'',A''));',...
%     'set(gcf,''windowbuttonmotionfcn'','''')'])
