I am trying to simulate population logistic growth

조회 수: 1 (최근 30일)
hafez ahmad
hafez ahmad 2020년 5월 9일
편집: Ameer Hamza 2020년 5월 9일
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
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’.
.

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by