Pr4oblem with an ODE 45 " not enough input arguments"
Show older comments
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
Accepted Answer
More Answers (1)
Cris LaPierre
on 7 Jan 2021
The ode solver expects the first two inputs to your odefun should be t and y (you can use any variable name you want, but this is what they represent). They are not defined in the code. Any additional input parameters come after that. Have a look at this example on the ode45 documentation page.
I agree your setup is unconventional. I would add that you use t incorrectly - both as the tspan input, and the odefun t input. Here's how you can modify the code to fix those issues at least.
ts = ts=linspace(0,burn_time,Nt);
y_0=[0,0];
[t_sol,y_sol]=ode45(@(t,y) zero_dmodelcc(t,y,C,A,v_cham,m_dot_pr,m_ox),ts,y_0);
function dy=zero_dmodelcc(t,y,C,A,v_cham,m_dot_pr,m_ox)
y1 = y(1);
y2 = y(2);
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!