How can i draw the phase portrait in my code for 3 non-linear coupled ODEs in 3D plane

4 views (last 30 days)
function SC1C2
clear
clc
clf
close all
%==== parameters =====
k1 = 1.5;
k_1 = 0.5;
k2 = 1;
k3 = 2;
k_3 = 1;
k4 = 3;
%======Initial conditions =====
initialx = 4;
initialy = 0;
initialz = 0;
runtime = 10; % Simulation run time
iterations = 1; % Sets iteration no. to 1
pausetime = 0.01; % Pause time between animation
az=-37.5; % Sets azemouth angle
el= 30; % Sets elevation angle.
deq1=@(t,x) [k_1*x(2)-k1*x(1)-k3*x(1)*x(2)-k_3*x(3);
k1*x(1)-(k_1+k2)*x(2)-k3*x(1)*x(2)+(k4+k_3)*x(3);
k3*x(1)*x(2)-(k4+k_3)*x(3)];
[t,sol] = ode45(deq1,[0 runtime],[initialx initialy initialz]);
arraysize = size(t);
for i = 1 : max(arraysize)
plot3(sol(iterations,1),sol(iterations,2),sol(iterations,3),'-o','markersize',6,'MarkerFaceColor','m')
hold on
grid on
xlabel('S','fontsize',12)
ylabel('C1','fontsize',12)
zlabel('C2','fontsize',12)
iterations = iterations + 1;
pause(pausetime)
axis([min(sol(:,1)) max(sol(:,1)) min(sol(:,2)) max(sol(:,2)) min(sol(:,3)) max(sol(:,3))])
view(az,el)
az = az+1;
end
end

Accepted Answer

William Rose
William Rose on 5 Dec 2021
Edited: William Rose on 5 Dec 2021
Matlabs quiver3() is very nice for this.
"quiver3(X,Y,Z,U,V,W) plots arrows with directional components U, V, and W at the Cartesian coordinates specified by X, Y, and Z. For example, the first arrow originates from the point X(1), Y(1), and Z(1), extends in the direction of the x-axis according to U(1), extends in the direction of the y-axis according to V(1), and extends in the direction of the z-axis according to W(1). By default, the quiver3 function scales the arrow lengths so that they do not overlap."
  10 Comments
Akhtar Jan
Akhtar Jan on 6 Dec 2021
thanks alot sir it works brilliant you are the greatest sir i love you..........
may God give you long and healthy life.ameen

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!