How to solve the Gompertz Equation
40 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I am trying to run a simple gompertz equation. however when I run the code below only one line generates instead of two. Anyone have any ideas how to fix this?
%Gompertz Equation
% Parameter and intial condtions
r= (0.349)
p= [2.913 3.929 5.308 7.239 9.638 12.866 17.069 23.191]';
k= 451.7
% Time interval
t = (1790:10:1860)';
%Gompertz Equation
E= k.*(p/k).^exp(-r*t);
% Time Interval
a=(1790:10:1860)';
% Population
b= [3.929 5.308 7.239 9.638 12.866 17.069 23.191 31.443]';
% Plot
plot (a,b,'bo');
hold on
plot(t,E,'r');
line_color=['r'];
hold off
legend('Gompertz Model','Census Data');
axis([1790 1860 0 50]);
title('US Population Data');
ylabel('Population (Millions)');
xlabel ('Years');
0 件のコメント
回答 (2 件)
Star Strider
2020 年 9 月 29 日
The reason the red line does not plot is that ‘b’ goes from about 3 to about 32, however ‘E’ is constant at about 451.7. So ‘E’ is off the scale of the plot as defined by the axis call.
The solution is to re-scale ‘E’ to match the range of ‘b’.
I leave that to you, since I have no idea what you are doing.
2 件のコメント
Star Strider
2020 年 9 月 29 日
‘Shouldnt the equation be resulting in a curve?’
Probably. How did you arrive at those particular parameters?
Walter Roberson
2020 年 9 月 29 日
r= (0.349)
t = (1790:10:1860)';
E= k.*(p/k).^exp(-r*t);
Okay, so -r*t is between -0.349*1790 and -0.349*1860 which is roughly -624 to -649. And when you exp() those you get values like 1E-280. When you raise a value to that power, you are pretty much raising it to 0, so there will be very little variation in the value of the expression after the k.* so the value of the expression will be essentially constant near the value of k.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!