Help with ODE45
34 ビュー (過去 30 日間)
古いコメントを表示
here is my function that i need to solve with ODE45
function fun1=y(x)
alfaf=-12;
alfap=-6;
pi=180;
Kte=23.76;
Kfe=32.23;
Kre=0;
Betaa=21.38;
c=0.075;
r=0.8;
Fic=31.3;
Tavs=320.76;
hteta=(r-sqrt(c*c+r*r-2*c*r*cosd(x-asind((c/r)*sind(pi-x)))));
Ktc=((Tavs/sind(Fic))*(cosd(atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))-atand(tand(atand(tand(alfaf)*cosd(x)+tand(alfap)*sind(x)))*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x)))))+tand(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x)))*tand(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x)))*sind(atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))))/sqrt(((cosd(Fic+atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))-atand(tand(atand(tand(alfaf)*cosd(x)+tand(alfap)*sind(x)))*cosd(1i)))^2)+((tand(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))^2)*((sind(atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))))^2))));
hteta=(r-sqrt(c*c+r*r-2*c*r*cosd(x-asind((c/r)*sind(pi-x)))));
Ktc=((Tavs/sind(Fic))*(cosd(atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))-atand(tand(atand(tand(alfaf)*cosd(x)+tand(alfap)*sind(x)))*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x)))))+tand(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x)))*tand(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x)))*sind(atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))))/sqrt(((cosd(Fic+atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))-atand(tand(atand(tand(alfaf)*cosd(x)+tand(alfap)*sind(psir)))*cosd(1i)))^2)+((tand(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))^2)*((sind(atand(tand(Betaa)*cosd(atand(tand(alfap)*cosd(x)+tand(alfaf)*sind(x))))))^2))));
y=(Ktc*hteta+Kte)*r;
end
end my ODE code
clc
clear all
close all
c=0.075;
r=0.8;
x0=0;
xf=180-acosd(c/(2*r));
xspan=[x0 xf];
[y,x]=ode45('fun1',xspan,x0);
here the error i got
Error using fun1
Too many input arguments.
Error in odearguments (line 87)
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 Untitled4 (line 9)
[y,x]=ode45('fun1',xspan,x0);
please help!!
0 件のコメント
回答 (1 件)
Steven Lord
2017 年 11 月 6 日
"The function dydt = odefun(t,y), for a scalar t and a column vector y, must return a column vector dydt of data type single or double that corresponds to f(t,y). odefun must accept both input arguments, t and y, even if one of the arguments is not used in the function."
Your function only accepts one input argument and so is not valid as the first input for ode45.
I also recommend you pass the function in as a function handle @fun1 rather than as the char vector 'fun1'.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!