MATLAB: I dont know what I am doing wrong. I keep on getting various error codes ode45 error,

errorerror code

function apoptosis
%
%file apoptosis.m
%Model of apoptosis signalling pathway
%modified from Eissing et al. (2004) Journal of Biological Chemistry 279, pp.
%36892-36897
%Figure 6.16
%assign paramter values
k1=507;
k2=3.9e-3;
k3=1e-5;
k4=5.8e-3;
k5=5e-4;
k6=0.21;
k7=81.9;
k8=3.9e-3;
k9=5.8e-6;
k10=5.8e-3;
k11=5e-4;
k12=0.21;
k13=40;
k14=1e-3;
k15=464;
k16=1.16e-2;
k17=3e-4;
k18=1.16e-2;
k19=1.73e-2;
input=0;
%assign initial condition. These values were taken from a previous
%simulation run to steadt state with input=0
%state vector S=[C8 C8star C3 C3star BAR IAP C8starBAR C3starIAP]
% d=[C8 C8star C3 C3star BAR IAP C8starBAR C3starIAP];
% dC8dt= k1 – k2*C8 – k3*(C3star+input)*C8;
% dC8stardt= k3*(C3star+input)*C8 -k4*C8star – k5*C8star*BAR + k6*C8starBAR;
% dC3dt= k7 – k8*C3 – k9*C8star*C3;
% dC3stardt=k9*C8star*C3 – k10*C3star – k11*C3star*IAP + k12*C3starIAP;
% dBARdt=k13-k5*C8star*BAR+k6*C8starBAR-k14*BAR;
% dIAPdt=k15-k11*C3star*IAP+k12*C3starIAP-k16*IAP-k17*C3star*IAP;
% dC8starBARdt=k5*C8star*BAR-(k6+k18)*C8starBAR;
% dC3starIAPdt=k11*C3star*IAP-(k12+k19)*C3starIAP;
C80=18000;
C8star0=0;
C30=120000;
C3star0=0;
BAR0=0;
IAP0=18000;
C8starBAR0=0;
C3starIAP0=0;
t0=0;
tF=1600;
initials=[C80,C8star0,C30,C3star0,BAR0,IAP0,C8starBAR0,C3starIAP0];
[t,S]=ode45(@dSdt,[t0 tF],initials,[],k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,input);
C8 = S(:,1);
C8star = S(:,2);
C3 = S(:,3);
C3star = S(:,4);
BAR = S(:,5);
IAP = S(:,6);
C8starBAR = S(:,7);
C3starIAP = S(:,8);
%generate figure
figure(1)
plot(t,S(:,2),'-b','LineWidth',2);
hold on;
plot(t,S(:,4),'-.k','LineWidth',2);
hold off;
%
legend('C8star', 'C3star')
axis([0 1600 0 100000])
xlabel('Time (min)')
ylabel('Concentration (molecules per cell)')
% Defining the ODE system
%dynamics
function dS = dSdt(t,S,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,input)
%assign time-varying profile for parameter 'input'
if t>300 && t<300+900
input=200;
end
%assign state variables
C8 = S(1);
C8star = S(2);
C3 = S(3);
C3star=S(4);
BAR=S(5);
IAP=S(6);
C8starBAR=S(7);
C3starIAP=S(8);
dS = [k1 – k2*C8 – k3*(C3star+input)*C8;
k3*(C3star+input)*C8 -k4*C8star – k5*C8star*BAR + k6*C8starBAR;
k7 – k8*C3 – k9*C8star*C3;
k9*C8star*C3 – k10*C3star – k11*C3star*IAP + k12*C3starIAP;
k13-k5*C8star*BAR+k6*C8starBAR-k14*BAR;
k15-k11*C3star*IAP+k12*C3starIAP-k16*IAP-k17*C3star*IAP;
k5*C8star*BAR-(k6+k18)*C8starBAR;
k11*C3star*IAP-(k12+k19)*C3starIAP];
end
end
-Below are the error codes that I keep on getting. I'm not too good w/ MATLAB so I don't fully understand the issue/error codes:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in apoptosis/dSdt (line 92)
dS = [k1 – k2*C8 – k3*(C3star+input)*C8;
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in apoptosis (line 54)
[t,S]=ode45(@dSdt,[t0 tF],initials,[],k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,input);

Best Answer

There are two problems:
First, In MATLAB, spaces are delimiters, so MATLAB gets confused if there are spaces between operations in matrix elements. The easiest way to deal with that is to put parentheses around every line in the ‘dS’ vector:
dS = [(k1 - k2*C8 - k3*(C3star+input)*C8);
(k3*(C3star+input)*C8 -k4*C8star - k5*C8star*BAR + k6*C8starBAR);
(k7 - k8*C3 - k9*C8star*C3);
(k9*C8star*C3 - k10*C3star - k11*C3star*IAP + k12*C3starIAP);
(k13-k5*C8star*BAR+k6*C8starBAR-k14*BAR);
(k15-k11*C3star*IAP+k12*C3starIAP-k16*IAP-k17*C3star*IAP);
(k5*C8star*BAR-(k6+k18)*C8starBAR);
(k11*C3star*IAP-(k12+k19)*C3starIAP)];
Second, the anonymous function in the ode45 call is wrong. The ode45 call should be:
[t,S]=ode45(@(t,S)dSdt(t,S,k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16,k17,k18,k19,input),[t0 tF],initials,[]);
With those two changes, your code works. Try your code with those changes. If there are still problems, I can post the entire corrected code if you want me to, since it runs for me without error now.
.