I am trying to simulate population logistic growth

4 visualizzazioni (ultimi 30 giorni)
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;

Risposte (1)

Star Strider
Star Strider il 9 Mag 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’.
.

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by