How to plot nullclines with differential equations
48 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Zachary David
el 4 de Oct. de 2021
Respondida: Star Strider
el 4 de Oct. de 2021
Im trying to plot nullclines on top of a mesh grid then use ode 45
i cant seem to get the nullclines on their though after googling for hours. This is my code:
x1min = -1; x1max = 6; x2min = -1; x2max = 6;
x1step = 0.3; x2step = 0.3;
[x1, x2] = meshgrid(x1min:x1step:x1max, x2min:x2step:x2max);
a = 1.5;
b=1.1;
g=2.5;
d=1.4;
dx1 = -a*x1+b*x1*x2;
dx2 = g*x2-d*x1*x2;
nullX1= -a + b.*x2;
nullX2= g - d.*x1;
quiver(x1, x2, dx1,dx2,'AutoScaleFactor',0.5)
axis([x1min x1max x2min x2max])
xlabel('$x1$','Interpreter','latex')
ylabel('$x2$','Interpreter','latex')
title('Vector field example','Interpreter','latex')
x=0:0.5:30;
plot(x,nullX1,'r-')
hold on
plot(x,nullX2,'k-')
hold on
*****It keeps telling my my vectors must be the same length, so not sure if im using the wrong parameters.
Thanks!
0 comentarios
Respuesta aceptada
Star Strider
el 4 de Oct. de 2021
Work-around —
x = linspace(0, 30, size(nullX1,1)); % Use 'linspace' To Create Correct Length 'x'
x1min = -1; x1max = 6; x2min = -1; x2max = 6;
x1step = 0.3; x2step = 0.3;
[x1, x2] = meshgrid(x1min:x1step:x1max, x2min:x2step:x2max);
a = 1.5;
b=1.1;
g=2.5;
d=1.4;
dx1 = -a*x1+b*x1*x2;
dx2 = g*x2-d*x1*x2;
nullX1= -a + b.*x2
nullX2= g - d.*x1
quiver(x1, x2, dx1,dx2,'AutoScaleFactor',0.5)
axis([x1min x1max x2min x2max])
xlabel('$x1$','Interpreter','latex')
ylabel('$x2$','Interpreter','latex')
title('Vector field example','Interpreter','latex')
% x=0:0.5:30;
x = linspace(0, 30, size(nullX1,1)); % Use 'linspace' To Create Correct Length 'x'
plot(x,nullX1,'r-')
hold on
plot(x,nullX2,'k-')
hold on
Experiment to get different results.
.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!