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 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 5 月 9 日
What is the question?

サインインしてコメントする。

回答 (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 Center および File ExchangeEquation Solving についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by