clear all;

A=[1 -3; 9 -2]       

[U,D] = eig(A)      
% A har komplekse egenverdier med negativ realdel

a = real(D(1,1));
b = imag(D(1,1));

y1 = []; y2 = [];

for t=-2:0.02:6;

y1 = [ y1 (real(U(:,1))*cos(b*t) - imag(U(:,1))*sin(b*t))*exp(a*t) ];
y2 = [ y2 (real(U(:,1))*sin(b*t) + imag(U(:,1))*cos(b*t))*exp(a*t) ];

end

%figure(4)
%plot(y1(1,:),y1(2,:),'g');

%figure(5)
%plot(y2(1,:),y2(2,:),'r');

figure(6)
hold on;

axis([-1.5 1.5 -2.5 2.5])
plot(y1(1,:),y1(2,:),'g');
plot(y2(1,:),y2(2,:),'r');

r=-1.5:0.2:1.5;
s=-2.5:0.2:2.5;

[x,y]=meshgrid(r,s);

u =  x - 3 * y;
v = 9 * x - 2 * y;

quiver(x,y,u,v);

