How to add arrows to solution trajectories using ode?
16 ビュー (過去 30 日間)
古いコメントを表示
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])
0 件のコメント
採用された回答
Star Strider
2014 年 9 月 2 日
編集済み: Star Strider
2014 年 9 月 2 日
2 件のコメント
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 Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!