![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287357/image.png)
3D Phase portrait for a set of differential equations
조회 수: 16 (최근 30일)
이전 댓글 표시
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.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287349/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287349/image.png)
Any help would be greately helpful. This is what I am getting from above code.
Thank You![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287351/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287351/image.jpeg)
댓글 수: 2
darova
2020년 4월 25일
Phase portrait it's a graph
and y. HOw to plot 3D phase portrait? What those axes represent
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287357/image.png)
채택된 답변
darova
2020년 4월 25일
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 ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287371/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287370/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287371/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287372/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287373/image.png)
댓글 수: 3
darova
2020년 4월 25일
- The graph I get has different colour scheme than shown in your diagram. Is that system specific or am i missing something.
It's because im from Poland. Poles like more red colors
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287452/image.jpeg)
colormap jet % try to change colormap
- The commented part of the code, what does this represent. I removed the comment and ran but found no difference in the plot.
Impossible! Maybe color axis (range) didn't after you uncommented. Try to add clf at the beginning of the script
clf
- I can only see one graph, unlike the two you have pictured above, dy/dt and dy. Do i have make some changes in the code to get that.
I just run the script, saved the picture. Then commented line and run again (save second picture)
- I am accepting the answer as it was helpful.
But i don't see any ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287453/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/287453/image.png)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!