Why the graph is not look like logistic graph?

4 views (last 30 days)
Hi, I have a problem in plotting logistic model graph. May I know what is the problem of my coding and how to solve it? I would be grateful that the answer that provided. Thanks!
Here is the source code:
%% Initialize Input
K = 100000000; % Carrying Capacity of Brain Tumor
C0 = 40000; % Initial Brain Tumor Population Size
r = 4.31*(10^-3); % Growth Rate of Brain Tumor Cells
%% Model Data
t = 730; % Time in Days
C = zeros(t,1) ;
C(1) = C0;
lastArray = {};
% Calculating Brain Tumor Population
for i=1:1:t-1
C(i+1) = (K*(C0*exp(r*i)))/(K-C0+C0*exp(r*i));
end
c=cumsum(C);
hold on
nvec = 1:1:t;
%% Graph Plotting
figure(1)
title( 'Brain Tumor Population Against Time' )
xlabel('Time (Days)')
ylabel('Brain Tumor Population (cells)')
plot(nvec,cumsum(C),'--bo','LineWidth',0.5,'MarkerSize',5,'MarkerEdgeColor','black')
grid
hold on
Here is the output:

Accepted Answer

Cris LaPierre
Cris LaPierre on 5 Jan 2022
Edited: Cris LaPierre on 5 Jan 2022
The most likely reasons are 1) you have not gone out far enough in x or 2) you have not written a logistic expression.
Note that r must be negative to have your logistic increase asymptotically, and >0 to decrease asymptotically to 0. Perhaps you just need to put a negative in front of r?
%% Initialize Input
K = 100000000; % Carrying Capacity of Brain Tumor
C0 = 40000; % Initial Brain Tumor Population Size
r = 4.31*(10^-3); % Growth Rate of Brain Tumor Cells
%% Model Data
t = 0:730; % Time in Days
% Calculating Brain Tumor Population
C = K*C0*exp(-r*t)./(K-C0+C0*exp(-r*t));
%% Graph Plotting
plot(t,cumsum(C),'--bo','LineWidth',0.5,'MarkerSize',5,'MarkerEdgeColor','black')
title( 'Brain Tumor Population Against Time' )
xlabel('Time (Days)')
ylabel('Brain Tumor Population (cells)')
grid
Still, I don't believe you should have to use a cumsum to get the results, and they still don't look like a typical logistic plot, so perhaps check your equation? For example, here's an equation that I think is more typical of logistic growth.
At , C=C0 and at , C=K. It is also able to obtain the expected results without using cumsum. I do make it go to 1400 to see the assymptote.
%% Initialize Input
K = 100000000; % Carrying Capacity of Brain Tumor
C0 = 40000; % Initial Brain Tumor Population Size
r = 4.31*(10^-3); % Growth Rate of Brain Tumor Cells
%% Model Data
t = 0:1400; % Time in Days
% Calculating Brain Tumor Population
C = K*(C0/K).^exp(-r*t);
%% Graph Plotting
figure
plot(t,C,'--bo','LineWidth',0.5,'MarkerSize',5,'MarkerEdgeColor','black')
title( 'Brain Tumor Population Against Time' )
xlabel('Time (Days)')
ylabel('Brain Tumor Population (cells)')
grid

More Answers (0)

Categories

Find more on Neuroimaging in Help Center and File Exchange

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!