How to make it accumarray?

Hi, may I ask that how to make it be accumulative array. I will be grateful that provide the idea. Thanks!
%% Initialize Input
K = 1*(10^-9); % 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 = 365; % Time in Days
C = zeros(t,1) ;
C(1) = C0;
% Calculating Brain Tumor Population
for i=2:1:t-1
C(i+1) = (K*(C0*exp(r*i)))/(K-C0+C0*exp(r*i));
end
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,C,'--bo','LineWidth',0.5,'MarkerSize',5,'MarkerEdgeColor','black')
grid
hold on

6 commentaires

Walter Roberson
Walter Roberson le 5 Jan 2022
Modifié(e) : Walter Roberson le 5 Jan 2022
What would be accumulated, using what as the key value ?
I have to wonder if what you want is cumsum()
Deck Zhan Sim
Deck Zhan Sim le 5 Jan 2022
Like the value that added to (K*(C0*exp(r*i)))/(K-C0+C0*exp(r*i)) function. It must be keep on adding.
Mathieu NOE
Mathieu NOE le 5 Jan 2022
I wonder if there is a mistake in the equation
C(i+1) = (K*(C0*exp(r*i)))/(K-C0+C0*exp(r*i));
where does it come from ?
the data drops so fast it seems a bit strange (seen here in log scale )
Deck Zhan Sim
Deck Zhan Sim le 5 Jan 2022
Modifié(e) : Deck Zhan Sim le 5 Jan 2022
@Mathieu NOE This is the formula that formulated
Deck Zhan Sim
Deck Zhan Sim le 5 Jan 2022
@Walter Roberson may i know if using cumsum(), how to apply it?
plot(nvec, cumsum(C), '--bo', 'LineWidth', 0.5, 'MarkerSize', 5, 'MarkerEdgeColor', 'black')

Connectez-vous pour commenter.

Réponses (0)

Catégories

Produits

Version

R2020a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by