# 3D Phase portrait for a set of differential equations

89 views (last 30 days)
Vira Roy on 25 Apr 2020
Commented: Vira Roy on 25 Apr 2020
I have a set of three differential equations and I want to make a phase portrait of them. I have some idea of using quiver or plot3 to get a phase portrait of a set of 3 differential equations. I am unable to do for this case.
Here is my attempt:
timerange= 0:0.5:350;
IC= [0.1,0,0];
IC1= [0.1,0.2,0];
[t,y] =ode45(@(t,y) fn(t,y),timerange, IC);
[t1,y1] =ode45(@(t,y) fn(t,y),timerange, IC1);
plot3(y(:,1),y(:,2),y(:,3));
hold on
plot3(y1(:,1),y1(:,2),y1(:,3));
grid
xlabel('T')
ylabel('A')
zlabel('I')
function rk1 =fn(t,y)
r=0.00173;K=0.03166;A0=0.4;gammaA=0.04;eps = 0.00055;rho= 0.025;alpha1= 1.30187;c1=0.63433;
I0= 0.3;gammaI=0.0208;
alpha= 0.0002802;
n= y(1);
A= y(2);
I= y(3);
rk1(1)= r*n*(1- n/K)+ alpha*A*n -eps*n*I;
rk1(2) = A0 - gammaA*A;
rk1(3) = I0 + (rho*I*n)/(alpha1+n) -c1*I*n - gammaI*I;
rk1=rk1(:);
endI
What I am doing is merely changing the initial conditions The actual result should be something like this.
Any help would be greately helpful. This is what I am getting from above code.
Thank You
##### 2 CommentsShowHide 1 older comment
Vira Roy on 25 Apr 2020
Edited: Vira Roy on 25 Apr 2020
Thanks for reply darova. I was trying to do as Lorenz attractor done by James adams in this code. I have three differential equations and wanted to get a plot similar to above one i have shown.
What I wanted to ask is that, Can we get that by just choosing some initial conditions and plot the three solutions against each other. If not If have to get a phase portrait in 3 dimensions how should I proceed.
Those axes represent the three variables in the differential equation. I, n and A. Similar to x ,y ,z in Lorentz attractor.
Thank you anyways Darova.

Sign in to comment.

### Accepted Answer

darova on 25 Apr 2020
I tried to plot T A and I separately. X Y Z axis represents T A and I respectively. Color represents derivative of T A or I
I used surface to plot color lines (plotted curves as surfaces, made them nx2 size)
derivative just difference
##### 3 CommentsShowHide 2 older comments
Vira Roy on 25 Apr 2020
The colors were somehow the same but the values are different. Saw that after adding the color bar.
Thanks for your help.

Sign in to comment.

### Categories

Find more on Surface and Mesh Plots in Help Center and File Exchange

R2019b

### Community Treasure Hunt

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

Start Hunting!