I want show ylabel like 36m, 38m, 40m on plot I have variable population, plz help

조회 수: 3 (최근 30일)
Ghazi 2024년 6월 18일
댓글: Voss 2024년 6월 18일
% Define parameters
PopSaudi22
Unrecognized function or variable 'PopSaudi22'.
P_0 = PopSaudi22.POPTOTL % Initial population (1 million)
r = 0.02; % Annual growth rate (2%)
t = 1:1:20; % Time in years from 0 to 50 with a step of 0.1
% Compute population over time
P = P_0 * exp(r * t)
% Plot the result
figure;
plot(t, P,'-o', 'LineWidth', 2);
xlabel('Time (years)');
ylabel('Population in million');
title('Exponential Population Growth');
grid on;
I use an equation this: P = P_0 * exp(r * t)

댓글을 달려면 로그인하십시오.

채택된 답변

Voss 2024년 6월 18일
P_0 = 1e6; % Initial population (1 million)
r = 0.02; % Annual growth rate (2%)
t = 0:0.1:50; % Time in years from 0 to 50 with a step of 0.1
% Compute population over time
P = P_0 * exp(r * t)
P = 1x501
1.0e+06 * 1.0000 1.0020 1.0040 1.0060 1.0080 1.0101 1.0121 1.0141 1.0161 1.0182 1.0202 1.0222 1.0243 1.0263 1.0284 1.0305 1.0325 1.0346 1.0367 1.0387 1.0408 1.0429 1.0450 1.0471 1.0492 1.0513 1.0534 1.0555 1.0576 1.0597
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Plot the result
figure;
plot(t, P/1e6,'-o', 'LineWidth', 2);
xlabel('Time (years)');
ylabel('Population in million');
title('Exponential Population Growth');
grid on;
ax = gca();
yt = get(ax,'YTick');
ax.YTickMode = 'manual';
ax.YTickLabel = yt+"m";
댓글 수: 2없음 표시없음 숨기기
Ghazi 2024년 6월 18일
wooow thank my bro very thank you u best in the world
Voss 2024년 6월 18일
You're welcome!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by