% Konstruktionsövning 3.2 Lösningsförslag


clear all ;
global A  ; 

clf ;
l = 0; 
xmax = 2 ;
dx = 0.2 ;
 
while  ( l ~= 1 ), 
clf ; hold on 
A = randn(2,2);
[V,D] = eig(A)
[x,y] =  meshgrid( -xmax:dx:xmax, -xmax:dx:xmax );   
V1 = A(1,1)*x+A(1,2)*y ; V2 = A(2,1)*x+A(2,2)*y ;

axis([-2, 2, -2, 2]);

quiver(x, y , V1, V2 );
plot(0,0, '*') ;

lp=sprintf('Lam_1= %1.2f+%1.2f i', real(D(1,1)), imag(D(1,1) ) ) ;
text(-xmax,-xmax - 1,  lp);
lp=sprintf('Lam_2= %1.2f+ %1.2f i', real(D(2,2)), imag(D(2,2) ) ) ;
text(-xmax + 2. ,-xmax -1,  lp);
plot(real( [-V(1,1), V(1,1)])*2 ,real( [ -V(2,1 ),V(2,1 )]*2) , 'b' );
plot(real( [-V(1,2), V(1,2)])*2 ,real( [ -V(2,2) ,V(2,2 )]*2) , 'b' );

l = input ( 'Will du undersöka den varianten ? (Y=1, N=0) ->  ' ) ;

end 

% Undersök varianter med olika start punkter. 
l = 1;
while  ( l ~= 0 ), 
DT = input('Put a useful value for time interval:  DT =  ' );
y0= ginput(1) ; 
[T,Y] = ode45('ode_myfile', [0  DT ], y0);
plot(Y(:,1), Y(:,2),'r');
l = input ( 'Will du undersöka en variant till ? (Y=1, N=0) ->  ' ) ;
end 








