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

1 Ansicht (letzte 30 Tage)
% 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)

Akzeptierte Antwort

Voss
Voss am 18 Jun. 2024
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";

Weitere Antworten (0)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by