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

3 vues (au cours des 30 derniers jours)
Ghazi
Ghazi le 18 Juin 2024
Commenté : Voss le 18 Juin 2024
% 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)

Réponse acceptée

Voss
Voss le 18 Juin 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";
  2 commentaires
Ghazi
Ghazi le 18 Juin 2024
wooow thank my bro very thank you u best in the world

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Tags

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by