Why the graph is not look like logistic graph?

조회 수: 3 (최근 30일)
Deck Zhan Sim
Deck Zhan Sim 2022년 1월 5일
댓글: Deck Zhan Sim 2022년 1월 6일
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:

채택된 답변

Cris LaPierre
Cris LaPierre 2022년 1월 5일
편집: Cris LaPierre 2022년 1월 5일
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
  댓글 수: 1
Deck Zhan Sim
Deck Zhan Sim 2022년 1월 6일
I managed to get it already. Thanks for helping!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Neuroimaging에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by