Logistic Population growth... w. linear regression and polyfit
1 回表示 (過去 30 日間)
古いコメントを表示
i've been giving the following initial data.
t=0:14; n=[105 118 139 164 189 214 240 265 290 316 330 348 363 369 373];
and have been asked to model. the following equation. and compare it to the curve produced by the above data set.
Nt+1=Nt+Nt(r-(r/K)*Nt) % for anyone unfamiliar this is an FDE.
i've also figured out that the above equation can be broken down into the equation below.
(Nt+1-Nt)/Nt=r-r/K*Nt ... where the left hand side can be identifed as the y axis and the RHS can be identified as the x- axis and that r and r/K can be determined through linear regression... and then K can be solved.
I've tried inputting coeff=polyfit(t,n,1) and get 21.1250 and 106.9917 as output. i feel like what i'm doing is right but my number don't make any sense. can anyone give me any feed back. any help is appreciated! thanks!
4 件のコメント
John D'Errico
2014 年 2 月 4 日
編集済み: John D'Errico
2014 年 2 月 4 日
(Nt + 1 - Nt)/(Nt) == 1/(Nt)
When t = 0, I wonder what happens? Very often when you have something that looks algebraically correct, it is still a poor thing to do using a computer.
回答 (1 件)
Paul
2014 年 2 月 4 日
編集済み: Paul
2014 年 2 月 4 日
I dont understand what you want to do with the fit but the numbers are correct:
coeff=polyfit(t,n,1)
n_fit = polyval(coeff,t)
figure;plot(t,n)
hold on;
plot(t,n_fit,'r')
legend('data','fit')
As you can see the fit is the best linear fit you'll get. The first value of coeff is the slope and the second is the constant.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!