I want show ylabel like 36m, 38m, 40m on plot I have variable population, plz help
2 次查看(过去 30 天)
显示 更早的评论
% Define parameters
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1718096/image.png)
0 个评论
采纳的回答
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)
% 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";
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!