Im trying to plot stable and unstable equilibrium solutions for my graph but Im not sure where or how to use the fzero function to do so for dx1 and dx2
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
close all; clear all;
% This Matlab code generates a vector field for the system of ODEs
% dx1/dt = f(x1,x2), dx2/dt = g(x1,x2)
x1min = -1; x1max = 6; x2min = -1; x2max = 6;
x1step = 0.5; x2step = 0.5;
[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;
dx1 = dx1./sqrt(dx1.^2 + dx2.^2);
dx2 = dx2./sqrt(dx1.^2 + dx2.^2);
axis([x1min x1max x2min x2max]);
xlabel('$x1$','Interpreter','latex')
ylabel('$x2$','Interpreter','latex')
title('Vector field example','Interpreter','latex')
nullX1= -a + b.*x2;
nullX2= g - d.*x1;
x=linspace(-1,6,size(nullX1,1));
quiver(x1, x2, dx1,dx2,'AutoScaleFactor',0.5)
hold on
plot(x,nullX1,'r-')
hold on
plot(x,nullX2,'k-')
hold on
legend('flow','nullX1','nullX2')
[t,x] = ode45(@ODE45Fun,[0,30],[0.5,1]);
plot(t,x(:,1),'g-',t,x(:,2),'b-')
hold on
fzero(dx1,0)
grid
xlabel('Number of Years')
ylabel('Predator-Prey Pop.')
title('Lotka Voltera Pred-Prey Pop.Figure1')
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Source Control Integration 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!