Problem with something that I do not understand
2 次查看(过去 30 天)
显示 更早的评论
Hi there i dont quite understand this problem it is saying
H=uold;
%frhs=@(H) -0.6*(((r^2)*(sqrt(2*g*H)))/((2*R*H)-H^2)); %The ODE
frhs=@(H) -0.6*((0.01*(sqrt(19.62*H)))/(((6*H)-(H^2))));
for the frhs, the output error shows, too many input arguement, what does it mean and how can i correct this mistake?
0 个评论
采纳的回答
Atsushi Ueno
2021-4-14
Now, frhs is a function with one argument H, so you can call the function like,
>> frhs=@(H) -0.6*((0.01*(sqrt(19.62*H)))/(((6*H)-(H^2))));
>> frhs(1)
ans =
-0.0053
but you cannot input more than one argument.
>> frhs(1,2)
error: @(H)-0.6*((0.01*(sqrt(19.62*H)))/(((6*H)-(H^2))))
too many input arguement
3 个评论
Atsushi Ueno
2021-4-14
Yes, why not? I'm not concerned about the correctness of the formula, I'm referring to the fact that frhs is an anonymous function that generates an error if the number of arguments don't match.
Steven Lord
2021-4-14
Show us how you're trying to use / call your frhs function. Based on the comment "%The ODE" I'm guessing you're trying to use this with one of the ODE solvers like ode45 in which case frhs does not satisfy the requirements ode45 places on the function you pass into it as the first input argument. [See the ode45 documentation page for information about those requirements.]
Even if your ODE function doesn't use both the inputs with which ode45 will call your ODE function it must accept both the inputs.
更多回答(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!