Phase Portrait Analysis of a 2x2 Matrix: Stability and Dynamics - Prof. Charles D. Levermo, Assignments of Differential Equations

This matlab script explores the phase portraits, eigenvectors, eigenvalues, and stability properties of a 2x2 matrix as the parameter u varies from -2 to 2. The script plots the representative trajectories, eigenvectors, and eigenvalues, and labels the plot with the trace and determinant of the matrix.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-36m
koofers-user-36m 🇺🇸

9 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Sarah Adelman MATH246 Extra Credit
%Phase plane as u goes from -2 to 2
for u=-2:.1:2
A=[u+1, -u; u ,u-1];
pplane(A)
hold on
end
function pplane(A)
% pplane.m Plots the eigenvectors, eigenvalues, and representative
% phase portraits for
%
% d[x; y]/dt = A[x; y]
%
% for -1<x<1, -1<y<1. Called as
%
% pplane(A)
%
% where A is the 2x2 coefficient array. Calls lodesolver.m,
% so be sure that function is in the current path
[U,S] = eig(A);
lam = diag(S);
if lam(1) == lam(2)
% manually set u2 to be orthogonal to u1
U(:,2) = [-U(2,1); U(1,1)];
end
figure
if isreal(lam(1))
plot([-U(1,1) U(1,1)],[-U(2,1) U(2,1)],'--', ...
[-U(1,2) U(1,2)],[-U(2,2) U(2,2)],'Linewidth',2)
legend('u_1','u_2')
else
plot(0,0,'o','MarkerSize',12,'LineWidth',2)
end
xlabel('x'), ylabel('y')
grid on
trA = A(1,1)+A(2,2);
detA = A(1,1)*A(2,2) - A(1,2)*A(2,1);
title(['tr(A) = ',num2str(trA),' det(A) = ',num2str(detA)])
tmax = sqrt(abs(lam(1))^2+abs(lam(2))^2)/2;
incr = 1/max(abs(lam))/20;
t = [0:0.05:tmax];
hold on
for i = 1:40
z0 = 2*rand(2,1)-[1;1];
z = lodesolver(A,t,z0);
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Phase Portrait Analysis of a 2x2 Matrix: Stability and Dynamics - Prof. Charles D. Levermo and more Assignments Differential Equations in PDF only on Docsity!

Sarah Adelman MATH246 Extra Credit %Phase plane as u goes from -2 to 2 for u=-2:.1: A=[u+1, -u; u ,u-1]; pplane(A) hold on end function pplane(A)

% pplane.m Plots the eigenvectors, eigenvalues, and representative % phase portraits for % % d[x; y]/dt = A[x; y] % % for -1<x<1, -1<y<1. Called as % % pplane(A) % % where A is the 2x2 coefficient array. Calls lodesolver.m, % so be sure that function is in the current path

[U,S] = eig(A);

lam = diag(S);

if lam(1) == lam(2) % manually set u2 to be orthogonal to u U(:,2) = [-U(2,1); U(1,1)]; end

figure

if isreal(lam(1))

plot([-U(1,1) U(1,1)],[-U(2,1) U(2,1)],'--', ... [-U(1,2) U(1,2)],[-U(2,2) U(2,2)],'Linewidth',2) legend('u_1','u_2') else plot(0,0,'o','MarkerSize',12,'LineWidth',2) end xlabel('x'), ylabel('y') grid on trA = A(1,1)+A(2,2); detA = A(1,1)A(2,2) - A(1,2)A(2,1); title(['tr(A) = ',num2str(trA),' det(A) = ',num2str(detA)])

tmax = sqrt(abs(lam(1))^2+abs(lam(2))^2)/2; incr = 1/max(abs(lam))/20; t = [0:0.05:tmax]; hold on for i = 1: z0 = 2*rand(2,1)-[1;1]; z = lodesolver(A,t,z0);

plot(z(1,:),z(2,:),'r.-') end hold off

H = axes('position',[0.1 0.75 0.2 0.2]); plot(real(lam(1)),imag(lam(1)),'bX',real(lam(2)),imag(lam(2)),'go', ... 0,0,'.','LineWidth',2) ax = axis; xrng = ax(2)-ax(1); yrng = ax(4)-ax(3); hold on plot([ax(1)-0.05xrng ax(2)+0.05xrng],[0 0],'r', ... [0 0],[ax(3)-0.05yrng ax(4)+0.05yrng],'r') axis tight hold off

set(H,'YTick',[]),set(H,'XTick',[])

drawnow

for u=-

for u=-1.

At u=-2 the phase plane is a spiral sink and as u increases to -1 it slowly straightens out to a radial sink.

At u goes from -1 to about -0.8 the phase plane is a nodal sink. As u goes from that to 0 it is a saddle and

continues to be a saddle, just on a tilt in the other direction until u reaches about 0.8 where the phase

plane is then a nodal source. At u=1 it is a radial source and from 1 to 2 it is a spiral source.