I am having error using ode45 with Inputs must be floats, namely single or double
4 次查看(过去 30 天)
显示 更早的评论
Hello scholar, I have a code am running and I keep getting this error after several try. what might be the error in my code? Below is the error shown and few lines where the error might have occured. Kindly help
Error using odearguments (line 113)
Inputs must be floats, namely single or double.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
omegap_r = @(r)omegap.*(1-(k_om.*r./a));
eps = @(r)@(omega) eps_inf - (omegap_r(r).^2./(omega.^2+(1i*omega.*gamma)));
opts = odeset('RelTol',1e-5,'AbsTol',1e-8);
[r,eps_bar] = ode45(@(r,eps_bar)@(omega) (eps(r).(omega)-eps_bar).*(eps_bar+2.*eps(r).(omega))./(r.*eps(r).(omega)),tspan,1,opts);
e_a = eps_bar(end)./eps_bar;
epsilon_e = @(omega) eps2+((3*eps2*f(y)).*((e_a(1)-eps2)./(e_a(1)+2*eps2)));
2 个评论
Walter Roberson
2021-11-17
Please show
whos a eps_inf gamma k_om omega omegap tspan
with tspan being most important for this purpose.
回答(1 个)
Steven Lord
2021-11-17
[r,eps_bar] = ode45(@(r,eps_bar)@(omega) (eps(r).(omega)-eps_bar).*(eps_bar+2.*eps(r).(omega))./(r.*eps(r).(omega)),tspan,1,opts);
The function handle you're passing into ode45 as its first input does not return a numeric value, it instead returns a function handle. This does not satisfy the requirements ode45 imposes on that function, namely that it return a numeric vector.
If you show us the mathematical form of the differential equations you're trying to solve we may be able to offer suggestions for how to modify your ode45 call's first input.
3 个评论
Steven Lord
2021-11-17
The equation you posted doesn't include omega at all. How does the program "call for omega"?
另请参阅
类别
在 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!