% =========================================================================
%  Biological_Models_Cancer_Cells.m
% 
%  Discrete Logistic-like Model for Cancer Cells  
%
% Note the behavior of the model at high growth rates
%
% =========================================================================
 
close all;
clear all;
 
% Discrete Logistic Model
% Investigate the long-time behavior of the model using
% different values of P0 and r
 
% create two vectors of zeros [t, p(t)]
N = 51; % number of all time periods to be checked
y = linspace(0,50,N);
%p = zeros(1,N);
 
% initial values for r, p
K = 1; % population is normalized, so capacity is 1
% different growth rates
r(1) = 1.5;
r(2) = 2.5;
r(3) = 3.0;
r(4) = 3.5;
r(5) = 4.0;
p(1:5,1) = 0.1;
 
% calculate population for all time periods for all growth rates
for i = 2:N
  p(1,i) = r(1)*p(1,i-1)*(1 - p(1,i-1));  
  p(2,i) = r(2)*p(2,i-1)*(1 - p(2,i-1));  
  p(3,i) = r(3)*p(3,i-1)*(1 - p(3,i-1));  
  p(4,i) = r(4)*p(4,i-1)*(1 - p(4,i-1));  
  p(5,i) = r(5)*p(5,i-1)*(1 - p(5,i-1));  
end

%plot data
figure (1);
hold on;
%plot (y,p(1,:),'b',y,p(2,:),'r',y,p(3,:),'g',y,p(4,:),'y',y,p(5,:),'black'); 
%legend('r=1.5','r=2.5','r=3.0','r=3.5','r=4.0');
plot (y,p(1,:),'black',y,p(2,:),'r',y,p(3,:),'b'); 
legend('r=1.5','r=2.5','r=3.0');
xlabel('Time Steps');
ylabel('Population');
hold off;

figure (2);
hold on;
plot (y,p(4,:),'black',y,p(5,:),'b'); 
legend('r=3.5','r=4.0');
xlabel('Time Steps');
ylabel('Population');
hold off;
