Phase portraits for autonomous linear ODE system

We consider the ODE system
with a nonsingular matrix . In this case there is one stationary point at .
We obtain the following types of stationary points:

REAL EIGENVALUES:

both positive
different
nodal source
unstable
equal
radial source or twist source (deficient case)
unstable
both negative
different
nodal sink
stable
equal
radial sink or twist sink (deficient case)
stable
positive & negative
saddle
unstable
Equal eigenvalues: if there are two eigenvectors we get a radial sink/source. If there is only one eigenvector we get a twist sink/source.

NONREAL EIGENVALUES:

real part positive
spiral source
unstable
real part negative
spiral sink
stable
real part zero
center
stable
We get a general solution
In the phase portaits below we always show eight trajectories: We use and (for we just get the constant solution ).
clearvars

Two different negative eigenvalues: NODAL SINK

A = sym([-4 -3; -1 -2])
A = 
The eigenvalues are
[V,D] = eig(A)
V = 
D = 
phaseportrait(A)

Note: for two different POSITIVE eigenvalues we get a NODAL SOURCE (phase portrait as above, but with arrows pointing in the other direction).

positive and negative eigenvalue: SADDLE

A = sym([1 2;4 -1])
A = 
The eigenvalues are
[V,D] = eig(A)
V = 
D = 
phaseportrait(A)

two equal negative eigenvalues, two eigenvectors: RADIAL SINK

A = sym([-2 0;0 -2])
A = 
The eigenvalues are
[V,D] = eig(A)
V = 
D = 
phaseportrait(A)

Note: for two equal POSITIVE eigenvalues, two eigenvectors we get a RADIAL SOURCE (phase portrait as above, but with arrows pointing in the other direction).

two equal negative eigenvalues, one eigenvector: TWIST SINK

A = sym([-1 -1;1 -3])
A = 
The eigenvalues are . There is only one eigenvector :
[V,D] = eig(A)
V = 
D = 
We have to find a generalized eigenvector satisfying : We can use e.g. :
[V,D] = jordan(A) % find eigenvectors and generalized eigenvectors
V = 
D = 
phaseportrait(A)

Note: for two equal POSITIVE eigenvalues, only one eigenvector we get a TWIST SOURCE (phase portrait as above, but with arrows pointing in the other direction).

nonreal eigenvalues, real part negative: SPIRAL SINK

A = sym([-1 5;-2 -3])
A = 
The eigenvalues are .
[V,D] = eig(A)
V = 
D = 
phaseportrait(A)

Note: for nonreal eigenvalues with POSITIVE real part we get a SPIRAL SOURCE (phase portrait as above, but with arrows pointing in the other direction).

nonreal eigenvalues, real part zero: CENTER

A = sym([1 -5; 1 -1])
A = 
The eigenvalues are .
[V,D] = eig(A)
V = 
D = 
phaseportrait(A)

Function for drawing phase portrait

function phaseportrait(A)
syms y(t) [2 1]
syms C1 C2
sol = dsolve(diff(y)==A*y); % solve ODE
ysol = subs(y(t),sol);
f = @(t,y) A*y; % define function f(t,y) for vectorfield
vectorfield(f,-5:5,-5:5); hold on
for c1=[-1 0 1]
for c2=[-1 0 1]
ys = subs(ysol,{C1,C2},{c1,c2}); % use C1=c1, C2=c2
fplot(ys(1),ys(2),[-5 5]); % plot trajectory for t=-5...5
end
end
hold off; axis equal; axis([-5 5 -5 5])
end