Problem with something that I do not understand

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?

 Akzeptierte Antwort

Atsushi Ueno
Atsushi Ueno am 14 Apr. 2021

0 Stimmen

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 Kommentare

Mark Loui
Mark Loui am 14 Apr. 2021
uold=2.75;
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))));
if based on your explaination it is safe to say that this should be right, is that right?
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.
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by