Population growth in 7 years

22 ビュー (過去 30 日間)
Ydd97
Ydd97 2019 年 11 月 15 日
コメント済み: Hend Nasrallah 2021 年 6 月 24 日
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

採用された回答

Fabio Freschi
Fabio Freschi 2019 年 11 月 15 日
% rate
r = 0.0063;
% years
t = 7;
% initial population
a = 5e6;
% population
y = a*(1+r)^t
  3 件のコメント
Fabio Freschi
Fabio Freschi 2019 年 11 月 15 日
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
Hend Nasrallah
Hend Nasrallah 2021 年 6 月 24 日
Hi i tried doing this question but the figure is not showing anything, it just giving me blank figure can I know what is the problem with the command ?

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

その他の回答 (1 件)

Fabio Freschi
Fabio Freschi 2021 年 6 月 24 日
Below you can find the output of the following code
% rate
r = 0.0063;
% years
t = 7;
% initial population
a = 5e6;
t = 1:7;
y = a*(1+r).^t;
figure,plot(t,y);
  1 件のコメント
Hend Nasrallah
Hend Nasrallah 2021 年 6 月 24 日
thank you, but i have question if we want to plot years for example from 2018 to 2025 how can we plot it using the same question and for loop.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by