How to plot nullclines with differential equations
47 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zachary David
am 4 Okt. 2021
Beantwortet: Star Strider
am 4 Okt. 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 Kommentare
Akzeptierte Antwort
Star Strider
am 4 Okt. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!