Phase Portraits of Differential Equations

Phase portraits of differential equations help visualize the response of a system to initial conditions and when represented in state-space form, how do the system space vector gets effected for zero input response as function of time.

phasePortrait


% Matlab Code for Phase Portraits
% Author: Abu Bakar Siddique
% Dated: 25-Mar-2016

clear all; close all; clc

[x1,x2] = meshgrid(-4:.5:4,-4:.5:4);

x1 = x1(:)'; x2 = x2(:)';

A1 = [-1 0; 0 -4];
A2 = [-2 -1; -2 -3];
A3 = [-2 0; 0 1];
A4 = [-3 -2; 2 2];
A5 = [-1 1; -1 -3];
A6 = [-2 1; 0 -2];
A7 = [2 -3; 6 -4];
A8 = [-1 2; -5 1];
A9 = [-3 1; 0 -2];
lineWidth = 3;

subplot (241);
xdot = A1*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 0], [0 1],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_1')

subplot (242)
xdot = A2*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 1], [-1 2],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_2')

subplot (243)
xdot = A3*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 0], [0 1],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_3')

subplot (244)
xdot = A4*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[-2 1], [1 -2],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_4')

subplot (245)
xdot = A5*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[-1 -1], [1 1],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_5')

subplot (246)
xdot = A6*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
hold on; quiver([0 0],[0 0],[1 1], [0 0],'r','linewidth',lineWidth); hold off
axis tight equal; title('A_6')

subplot (247)
xdot = A7*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
% hold on; quiver([0 0],[0 0],[1 1], [-1 1],'r'); hold off
axis tight equal; title('A_7')

subplot (248)
xdot = A8*[x1; x2];x1d = xdot(1,:); x2d = xdot(2,:);mag = sqrt(x1d.^2 + x2d.^2);quiver(x1,x2,x1d./mag, x2d./mag,'b');
% hold on; quiver([0 0],[0 0],[1 1], [-1 1],'r'); hold off
axis tight equal; title('A_8')

ha = axes('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0
1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'off');

text(0.5, 1,'\bf Phase Portrait Plots submitted by Abu Bakar Siddique: 2013-Phd-Elect-008)','HorizontalAlignment' ,'center','VerticalAlignment', 'top')

quiver(X,Y,U,V) plots velocity vectors as arrows with components (u,v)
at the points (x,y). The matrices X,Y,U,V must all be the same size
and contain corresponding position and velocity components (X and Y
can also be vectors to specify a uniform grid). quiver automatically
scales the arrows to fit within the grid.

Advertisements

Comments Invited

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s