%
%  codeHW08b -- 11 nov 02 -- djm
%
%  modified direction field plotting code
%  - called by codeHW8a
%

[ve , ei] = eig(A);
eigenvalues = diag(ei).'
first_eigenvector = ve(:,1);
second_eigenvector = ve(:,2);

%  make grid matrices

dx  = 0.2;  L = 1;
xt1 = -L-dx/2:dx:L+dx/2;
xt2 = -L-dx/2:dx:L+dx/2;

[xg1,xg2] = meshgrid(xt1,xt2);

xp1 = A(1,1)*xg1 + A(1,2)*xg2;
xp2 = A(2,1)*xg1 + A(2,2)*xg2;

r = sqrt(xp1.^2 + xp2.^2);

quiver(xt1,xt2, xp1./r, xp2./r,0.25,'k')
quiver(xt1,xt2,-xp1./r,-xp2./r,0.25,'k.')

axis equal
axis([-1 1 -1 1]*L)

%  label plot ("\bf"-prefix makes text boldface)

title(['\bf direction field'])
xlabel('\bf x_1(t)-axis')
ylabel('\bf x_2(t)-axis')

