I am trying to simulate population logistic growth
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
syms rm n k no t th
n=simplify(dsolve('Dn=rm*n*(1-(n/k)^th)','n(0)=no','t'))
no=10;
rm=0.6;
k=100;
th= 1; %theta
n=0:1:110;
figure
hold on
th= 1;
plot(t,eval(vectorize(n)),'k')
th=2;
plot(t,eval(vectorize(n)),'g')
th=3;
plot(t,eval(vectorize(n)),'r')
th=0.3;
Antworten (1)
Star Strider
am 9 Mai 2020
If you have R2012a or later, use symbolic functions.
Try this slightly modified version of your code (run in R2020a):
syms rm n(t) k no t th
no=10;
rm=0.6;
k=100;
% th= 1; %theta
Dn = diff(n);
n=simplify(dsolve(Dn == rm*n*(1-(n/k)^th), n(0)==no))
nfcn = matlabFunction(n) % Create Executable Function For fnc As ‘nfcn(t,th)’
t=0:1:110;
figure
hold on
th= 1;
plot(t,nfcn(t,th),'k')
th=2;
plot(t,nfcn(t,th),'g')
th=3;
plot(t,nfcn(t,th),'r')
th=0.3;
hold off
The curves are the same after about ‘t=20’.
.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Equation Solving 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!