A = [1 3; 4 2];

close all; 
figure; hold on;
Ax = ([-1,1,-1,1])

x = -10+20*rand(2,1); 
x = x/norm(x);
h(1) = PlotVector(x,'.r',Ax);
legend([h(1)],'Random Vector');
disp('A random vector');
pause(1);

[v,l] = eig(A);
% Find largest eigenvalue
L = [l(1) l(4)];
[m,mi] = max(abs(L));
v = v(:,mi)/norm(v(:,mi));


PlotVector(v,'.k',Ax);
h(2) = PlotVector(-v,'.k',Ax);
legend([h(1),h(2)],'Random Vector', 'Dominant EigenSpace');

disp('The eigenspace corresponding to the dominant eigenvalue');
pause(1);

for i = 1:15;
	x = A*x;
	x = x/norm(x);

	h(3) = PlotVector(x,'.b',Ax);
	legend([h(1),h(2),h(3)],'Random Vector', 'Dominant EigenSpace','Iterates of Random Vector');
	drawnow;
	pause(1/i);
end


