Logistic Population growth... w. linear regression and polyfit

6 views (last 30 days)
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 Comments
John D'Errico
John D'Errico on 4 Feb 2014
Edited: John D'Errico on 4 Feb 2014
(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.

Sign in to comment.

Answers (1)

Paul
Paul on 4 Feb 2014
Edited: Paul on 4 Feb 2014
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.

Community Treasure Hunt

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

Start Hunting!