필터 지우기
필터 지우기

How to add arrows to solution trajectories using ode?

조회 수: 13 (최근 30일)
Rose
Rose 2014년 9월 2일
댓글: Star Strider 2014년 9월 2일
I have a system of two odes and i want to plot the phase portrait with arrows and clearly representing the stable and unstable steady states. The problem is that i am getting the solution trajectories but without arrows. So it is very difficult to see which steady state is stable. Here is the ode system:
function dy = twodim(~,y, mu, d1, d2, K, n, p, sigma1, sigma2)
dy(1,1) = mu.*((y(1) + y(2)).^n)./(K.^n + (y(1) + y(2)).^n) - d1.*y(1) - y(1).*(sigma1 - sigma2.*(y(2)./(y(1) + y(2) + 1e-12))) ;
dy(2,1) = y(1).*(sigma1 - sigma2.*(y(2)./(y(1) + y(2) + 1e-12))) - (p + d2).*y(2);
Below is the part of the code I use to draw the solution trajectories:
mu = 2000;
K = 27000;
d1 = 0;
d2 = 0;
sigma1 = 0.25;
sigma2 = 0.75;
p = 0.24;
n = 1;
close all; hold on
for a = 0:5250:15000
for b = 0:5250:15000
[t, y] = ode45(@(t,y)twodim(t,y, mu, d1, d2, K, n, p, sigma1, sigma2), 0:0.2:15000, [a; b]);
plot(y(:,1), y(:,2))
end
end
hold off
axis([0 15000 0 15000])

채택된 답변

Star Strider
Star Strider 2014년 9월 2일
편집: Star Strider 2014년 9월 2일
Meet the quiver function.
The odephas2 output function is also worth a look, although I’ve never used it.
  댓글 수: 2
Rose
Rose 2014년 9월 2일
i tried the quiver function but it doesn't draw arrows along with the solution trajectories only, it draws them on the whole grid.
Star Strider
Star Strider 2014년 9월 2일
I’m not quite sure I understand the problem, or your ODE, so I don’t know if this is what you want. It is sometimes necessary to experiment with quiver:
arowscal = 10;
quiver(y(:,1), y(:,2), gradient(-y(:,1)), gradient(y(:,1)), arowscal )
The ‘arowscal’ parameter lengthens the arrows so you can see them.
I’m not aware of any other way to add arrows to plots, although there may be some File Exchange routines that will do it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by