I am trying to simulate population logistic growth
1 次查看(过去 30 天)
显示 更早的评论
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;
回答(1 个)
Star Strider
2020-5-9
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!