Problem with something that I do not understand

2 ビュー (過去 30 日間)
Mark Loui
Mark Loui 2021 年 4 月 14 日
コメント済み: Steven Lord 2021 年 4 月 14 日
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?

採用された回答

Atsushi Ueno
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
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
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 ExchangeProgramming についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by