how to add arrow on phase portrait
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Latifah
el 12 de Feb. de 2023
Respondida: Star Strider
el 12 de Feb. de 2023
I still have some difficulties to add the arrowheads nicely on the curved trajectories. With dynamics on the script is now fixed, you may post a new question on the arrowhead plotting issue . i want output like this but i still have no arrow code
to = 0;
tf = 30;
tspan = to:0.1:tf;
iv1 = [ 12.3 0.1 0 0.1 0.1 ] ;
[t y] = ode45(@(t, y) lnear(t, y), tspan, iv1);
plot(y(:,1), y(:,5)), hold on
iv2 = [ 12.3 0 0 0 0 ] ;
[t x] = ode45(@(t, x) lnear(t, x), tspan, iv2);
plot(x(:,1), x(:,5)),
iv3 = [ 12.65 0 0 0.1 0.1 ] ;
[t z] = ode45(@(t, z) lnear(t, z), tspan, iv3);
plot(z(:,1), z(:,5)),
iv4 = [ 12.65 0.1 0.1 0 0 ] ;
[t n] = ode45(@(t, n) lnear(t, n), tspan, iv4);
plot(n(:,1), n(:,5)),
iv5 = [ 12.485594 0 0 0 0.12 ] ;
[t w] = ode45(@(t, w) lnear(t, w), tspan, iv5);
plot(w(:,1), w(:,5)),
iv6 = [ 12.3 0.1 0 0.1 0 ] ;
[t v] = ode45(@(t, v) lnear(t, v), tspan, iv6);
plot(v(:,1), v(:,5)),
iv7 = [ 12.4 0.05 0 0.05 0 ] ;
[t s] = ode45(@(t, s) lnear(t, s), tspan, iv7);
plot(s(:,1), s(:,5)),
iv8 = [ 12.65 0.05 0 0.05 0.05 ] ;
[t p] = ode45(@(t, p) lnear(t, p), tspan, iv8);
plot(p(:,1), p(:,5)),
iv9 = [ 12.6 0.05 0 0.05 0 ] ;
[t c] = ode45(@(t, c) lnear(t, c), tspan, iv9);
plot(c(:,1), c(:,5)), grid on
xlabel('y_1'), ylabel('y_5')
function dydt = lnear(t,y)
dydt = zeros(5, 1);
e1 = 13;
g = 0.0125;
h = 0.284253;
f = 0.05;
q1 = 0;
k1 = 10;
d1 = 0.0412;
e2 = 0.0188;
j = 0.0082;
q2 = 0;
k2 = 10;
d2 = 0.0288;
b = 2;
d4 = 0.1152;
e3 = 0.166667;
a = 1.7;
q3 = 0;
k3 = 10;
d3 = 0.1152;
r = 0.5;
m = 1.02;
q4 = 0;
k4 = 10;
dydt(1) = e1 + (g*y(3)*y(1)/(h + y(3))) + (f*y(3)*y(1)) - (y(1)*(1 + ((q1/k1)*y(1)))) - (d1*y(1));
dydt(2) = e2*y(2) + (f*y(1)*y(3)) - (j*y(2)) - (y(2)*(1 + ((q2/k2)*y(2)))) - (d2*y(2));
dydt(3) = (b*e2*y(2)) - (d4*y(3));
dydt(4) = e3*y(4) + (j*y(2)) - (a*y(4)) - (y(4)*(1 + ((q3/k3)*y(4)))) - (d3*y(4));
dydt(5) = (r*y(5)*(1 - (m*y(5)))) + (a*y(4)) - y(5)*(1 + ((q4/k4)*y(5)));
end
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Feb. de 2023
to = 0;
tf = 30;
tspan = to:0.1:tf;
plotArrows = @(m) quiver(m(:,1), m(:,5), gradient(m(:,1)), gradient(m(:,5)));
figure
iv1 = [ 12.3 0.1 0 0.1 0.1 ] ;
[t y] = ode45(@(t, y) lnear(t, y), tspan, iv1);
plotArrows(y), hold on
iv2 = [ 12.3 0 0 0 0 ] ;
[t x] = ode45(@(t, x) lnear(t, x), tspan, iv2);
plotArrows(x),
iv3 = [ 12.65 0 0 0.1 0.1 ] ;
[t z] = ode45(@(t, z) lnear(t, z), tspan, iv3);
plotArrows(z),
iv4 = [ 12.65 0.1 0.1 0 0 ] ;
[t n] = ode45(@(t, n) lnear(t, n), tspan, iv4);
plotArrows(n),
iv5 = [ 12.485594 0 0 0 0.12 ] ;
[t w] = ode45(@(t, w) lnear(t, w), tspan, iv5);
plotArrows(w),
iv6 = [ 12.3 0.1 0 0.1 0 ] ;
[t v] = ode45(@(t, v) lnear(t, v), tspan, iv6);
plotArrows(v),
iv7 = [ 12.4 0.05 0 0.05 0 ] ;
[t s] = ode45(@(t, s) lnear(t, s), tspan, iv7);
plotArrows(s),
iv8 = [ 12.65 0.05 0 0.05 0.05 ] ;
[t p] = ode45(@(t, p) lnear(t, p), tspan, iv8);
plotArrows(p),
iv9 = [ 12.6 0.05 0 0.05 0 ] ;
[t c] = ode45(@(t, c) lnear(t, c), tspan, iv9);
plotArrows(c), grid on
xlabel('y_1'), ylabel('y_5')
function dydt = lnear(t,y)
dydt = zeros(5, 1);
e1 = 13;
g = 0.0125;
h = 0.284253;
f = 0.05;
q1 = 0;
k1 = 10;
d1 = 0.0412;
e2 = 0.0188;
j = 0.0082;
q2 = 0;
k2 = 10;
d2 = 0.0288;
b = 2;
d4 = 0.1152;
e3 = 0.166667;
a = 1.7;
q3 = 0;
k3 = 10;
d3 = 0.1152;
r = 0.5;
m = 1.02;
q4 = 0;
k4 = 10;
dydt(1) = e1 + (g*y(3)*y(1)/(h + y(3))) + (f*y(3)*y(1)) - (y(1)*(1 + ((q1/k1)*y(1)))) - (d1*y(1));
dydt(2) = e2*y(2) + (f*y(1)*y(3)) - (j*y(2)) - (y(2)*(1 + ((q2/k2)*y(2)))) - (d2*y(2));
dydt(3) = (b*e2*y(2)) - (d4*y(3));
dydt(4) = e3*y(4) + (j*y(2)) - (a*y(4)) - (y(4)*(1 + ((q3/k3)*y(4)))) - (d3*y(4));
dydt(5) = (r*y(5)*(1 - (m*y(5)))) + (a*y(4)) - y(5)*(1 + ((q4/k4)*y(5)));
end
Make appropriate changes to get the result you want.
.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!