The picture is a script and the content below is a command window.
Why can't I use the ode45 function?... only my computer has the error ,,ToT
>>Report
Error occurred during use: ode45
Too many input arguments.
Error occurred: report (line 7)
[t,x] ode45('step2'tspan,ic);
this is the Command Window
Why can't I use the ode45 function?

1 件のコメント

Walter Roberson
Walter Roberson 2019 年 5 月 29 日
What shows up for
which -all ode45
Note: we recommend you use
[t, x] = ode45(@step2, tspan, ic);

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2019 年 5 月 29 日

0 投票

The function you posted is called ‘step’, not ‘step2’. (The ’step’ function is the name of several built-in MATLAB functions. Always check to be certain you have not done that with respect to your functions or variables. This is called ‘overshadowing’ of built-in MATLAB functions, and is to be strictly avoided.)
First, rename your function ‘step2’, and save it as ‘step2.m’.
Then, try this:
[t,x] = ode45(@step2, tspan, ic);
Note that this uses the function handle reference to your function.

1 件のコメント

Walter Roberson
Walter Roberson 2019 年 5 月 29 日
In MATLAB the first function in a file is to be called according to the filename, not according to the function name, in case of a disagreement. As the file is step2.m it is acceptable to MATLAB to use a different function name inside step2.m . It is, though, confusing to the reader.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

タグ

質問済み:

2019 年 5 月 29 日

コメント済み:

2019 年 5 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by