function [Ca,Cb,La,Lb] = ploteig(A,range) % Plots the eigenvectors for a 2-D coefficient matrix A % test for size [m,n] = size(A); if m ~= 2 | n ~= 2 'Matrix is not 2-D - quitting.' return end % eigenanalysis and test for real result [c,l] = eig(A); Ca = c(:,1); Cb = c(:,2); La = l(1,1); Lb = l(2,2); if ~isreal(c) 'Eigenvectors/values are imaginary - quitting.' return end % eigenvector A x = -range:range; slope = Ca(2)/Ca(1); y = slope*x; clf; hold on; grid; plot(x,y,'r-'); %eigenvector B slope = Cb(2)/Cb(1); y = slope*x; plot(x,y,'b-');