How to add arrows to solution trajectories using ode?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rose
am 2 Sep. 2014
Kommentiert: Star Strider
am 2 Sep. 2014
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 Kommentare
Akzeptierte Antwort
Star Strider
am 2 Sep. 2014
Bearbeitet: Star Strider
am 2 Sep. 2014
2 Kommentare
Star Strider
am 2 Sep. 2014
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!