MATLAB Answers

Population growth in 7 years

조회 수: 45(최근 30일)
Ydd97
Ydd97 15 Nov 2019
Hi,
I want to make a graph that will calculate how the population will change in 7 years in a spesific country. Say in 2018 there is approximately 5 million people in a country, and the growth rate is 0.63%. What will the approximated population be in 2025? Is there anyone that can help me code this.
I have already calculated this using expontential euqation:
y= a(1+r)^t
P = 5(1.0063)^7
P = 5.22 million

  댓글 수: 0

로그인 to comment.

채택된 답변

Fabio Freschi
Fabio Freschi 15 Nov 2019
% rate
r = 0.0063;
% years
t = 7;
% initial population
a = 5e6;
% population
y = a*(1+r)^t

  댓글 수: 2

Ydd97
Ydd97 15 Nov 2019
Hi, thank you so much for helping me :)
Just wondering if I want to make a graph out of this, is it possible to use
for i=1:y
and then plot for (t,y) ?
Fabio Freschi
Fabio Freschi 15 Nov 2019
you must create a vector for the years and for the populations. For this you can use a for loop
for i = 1:7
t(i) = i;
y = a*(1+r)^t(i);
end
figure,plot(t,y)
or, better, use a vectorized notation
t = 1:7;
y = a*(1+r).^t;
figure,plot(t,y);
Hope it helps.
Please accept the answer if you are satisfied

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by