MATLAB: ‘ODE 23: Error using vertcat Dimensions of matrices being concatenated are not consistent.’

ode23ode45

Here is the code I'm having trouble with. It's a really simple code so I'm sure anyone can help. Basically I'm just taking the integral of four ODE functions but as you can see I am faced with some errors. I am new to matlab (and not a programmer at all) and I'm not sure what the error means or where it's coming from so please try to explain in the simplest manner how to fix it as well as what is happening.

Best Answer

[t,x] = ode45(@Task6,[0 10],[1;0;1;0]) %proper function call ode45 or ode23 solves without any problem
% Time span ---^--^ ^-----^-- Initial conditions
plot(t,x)
function derivative = Task6(IV,DV) %function definition
umax=1;
kd=0.013;
Ks=3.24;
D=0.207;
Cc_M=DV(1);
Cs_M=DV(2);
Cc_CA=DV(3);
Cs_CA=DV(4);
derivative = [-D*Cc_M + ((umax*Cs_M*Cc_M) / (Ks + Cs_M)) - kd*Cc_M;
D - D*Cs_M - ((umax*Cs_M*Cc_M) / (Ks + Cs_M));
-D*Cc_CA + umax*Cs_CA*(Cc_CA)^2 - kd*Cc_CA;
D - D*Cs_CA - umax*Cs_CA*(Cc_CA)^2];
end