In: Advanced Math
ODE: draw the phase by MATLAB ?′1=−8?1−2?2 and ?′2=2?1−4?2
%Matlab code for plotting of phase space
clear all
close all
%loop for phase space plot
for i=-2:.5:2
for j= -2:.5:2
[t,y] = ode45(@vdp1,[0 4],[i;j]);
hold on
plot(y(:,1),y(:,2),'r--')
end
end
%lebelling the plot
xlabel('y1')
ylabel('y2')
title('Phase space diagram')
%functions for which phase space have to draw
function dydt = vdp1(t,y)
dydt = [-8*y(1)-2*y(2);
2*y(1)-4*y(2)];
end
%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%