How to resolve this

18 ビュー (過去 30 日間)
Shweta
Shweta 2024 年 6 月 7 日
回答済み: Taylor 2024 年 7 月 2 日
N1=function('N1')(t)
Error: Function definitions are not supported in this context. Functions can only be created as local or nested functions in code files.
  2 件のコメント
Torsten
Torsten 2024 年 6 月 7 日
What's the purpose of the line ?
Aquatris
Aquatris 2024 年 6 月 7 日
編集済み: Aquatris 2024 年 6 月 7 日
Matlab expects functions to be defined as:
function y = myFun(x)
%% YOUR FUNCTION GOES HERE %%
end
Also, within a script, they can only be defined in this way at the end of the script.

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

回答 (1 件)

Taylor
Taylor 2024 年 7 月 2 日
As stated, functions in MATLAB must be defined as:
function y = myFunc(x)
%% Do something
end
If the function is in a file by itself, the file name must be the function name. Terminating with an "end" statement is optional in this case. If the function is defined within a script, it may be placed anywhere as of R2024a.

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by