function eignmovy(A,n,s) % % Call sequences: eignmovy (self-demonstrating) % eignmovy(A), eignmovy(A,n), eignmovy(A,n,s) % % This program visualizes eigenvectors % for 2x2 matrices. A is a 2x2 matrix. % n is optional and determines the number % of vectors drawn. The third (optional) % parameter determines the number of times % that the movie is played. % It is based on an idea by Gilbert Strang: % As a reference see the CMJ vol.26,no4, % September 1995, p.316 (S. Schonefeld). % Typical examples use the matrices: % A=[13 9;3 7]/8; (fairly generic) % A=[cos(pi/4) -sin(pi/4);sin(pi/4) cos(pi/4)]; % (nonreal eigenvalues) % A=[2 -2; -1 1]; (one zero eigenvalue) % A=[2-sqrt(3) -3; 1 2+sqrt(3)]/2; (double e.value) % % Written by M.Kawski, October 1995 % Display colors etc updated August 1999 % http://math.la.asu.edu/~kawski % % SHOULD be reworked using double buffering and slow-down. if nargin == 0 A=[13 9;3 7]/8; end; if nargin < 3 s=3; end; if nargin < 2 n=120; end; % E=moviein(n+1); phi=2*pi/n; z=zeros(1,n+1); x=cos(phi*[0:n]); y=sin(phi*[0:n]); v=A(1,:)*[x;y]; w=A(2,:)*[x;y]; m=max([1,max(abs(v)),max(abs(w))]); clf plot(x,y,'y-',v,w,'g-'); axis([-m,m,-m,m]) axis equal axis('on'); whitebg([0 0 0]) hold on p=plot([0;x(1)],[0;y(1)],'m-',... [0;v(1)],[0;w(1)],'c-'); % hold on for j=1:s for i=1:n+1 % hold off set(p(1),'XData',[0;x(i)],'YData',[0;y(i)]); set(p(2),'XData',[0;v(i)],'YData',[0;w(i)]); drawnow % E(:,i)=getframe; end; end; %movie(E,s,3);