How to solve the Gompertz Equation
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
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 comentarios
Respuestas (2)
  Star Strider
      
      
 el 29 de Sept. de 2020
        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 comentarios
  Star Strider
      
      
 el 29 de Sept. de 2020
				‘Shouldnt the equation be resulting in a curve?’  
Probably.  How did you arrive at those particular parameters?  
  Walter Roberson
      
      
 el 29 de Sept. de 2020
        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 comentarios
Ver también
Categorías
				Más información sobre Assembly en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!