Problem with something that I do not understand

1 visualización (últimos 30 días)
Mark Loui
Mark Loui el 14 de Abr. de 2021
Comentada: Steven Lord el 14 de Abr. de 2021
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?

Respuesta aceptada

Atsushi Ueno
Atsushi Ueno el 14 de Abr. de 2021
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 comentarios
Atsushi Ueno
Atsushi Ueno el 14 de Abr. de 2021
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
Steven Lord el 14 de Abr. de 2021
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by