MATLAB: Pr4oblem with an ODE 45 ” not enough input arguments”

matlab functionmatrix manipulationode45

I have problem withis system of ode , this is onlya part of the code
N.B I have the latest version of MatLab.
Thanks for your help
Nt=150
m_ox=0.7;
m_ox=m_ox.*ones(1,Nt);
r_dot=0.0006
m_dot_pr=1.7 ;
v_cham=1*10^(3);
m_fuel= 15.*ones(1,Nt);
burn_time=50;
t=linspace(0,burn_time,Nt)
C=((m_dot_fuel+m_ox-m_dot_pr)./(v_cham)) ;
A=((4*r_dot)./Dp_t);
y1_0=zeros(Nt,1);
y1_0=y1_0(:);
t=t(:);
y2_0=rho_ox_0.*ones(1,Nt);
y2_0=y2_0(:);
y_0=[y1_0,y2_0];
[t_sol,y_sol]=ode45(@(t,y1,y2)zero_dmodelcc(C,A,y1,y2,t,v_cham,m_dot_pr,m_ox),t,y_0);
function dy=zero_dmodelcc(C,A,y1,y2,t,v_cham,m_dot_pr,m_ox)
y=[y1;y2];
v_cham=v_cham(:);
m_ox=m_ox(:);
C=C(:);
A=A(:);
dy1 =C-(y1.*A);
dy1=dy1(:);
dy2=((y1.*m_ox)./(v_cham))+y2.*(A-m_dot_pr);
dy2=dy2(:);
dy=[dy1,dy2];
end

Best Answer

Your definition of the ODEs is unconventional. I've always used to define coupled ODEs such that the dependent variables are in one array in the input, not as two separate ones. So, according to my understanding you should modify the zero_dmodelcc function like this:
function dy=zero_dmodelcc(C,A,y1y2,t,v_cham,m_dot_pr,m_ox)
y1 = y1y2(1); % or perhaps y1 = y1y2(1:end/2);
y2 = y1y2(2); % and if so y2 = y1y2(end/2+1:end);
v_cham=v_cham(:);
m_ox=m_ox(:);
C=C(:);
A=A(:);
dy1 =C-(y1.*A);
dy1=dy1(:);
dy2=((y1.*m_ox)./(v_cham))+y2.*(A-m_dot_pr);
dy2=dy2(:);
dy=[dy1(:);dy2(:)]; % Should be a column-vector IIRC
end
Further you somehow define the initial conditions to be of the same size as the time-variable. That doesn't make sense. Something is likely off.