if nested functions supported in live scripts

6 ビュー (過去 30 日間)
feynman feynman
feynman feynman 2024 年 2 月 27 日
コメント済み: feynman feynman 2024 年 2 月 27 日
Are nested functions supported in live scripts? Otherwise, global variables have to be declared as global?
  6 件のコメント
Dyuman Joshi
Dyuman Joshi 2024 年 2 月 27 日
A function needs to be called by using its name and providing any inputs required to run it. That is the case in both functions (.m) and live functions (.mlx).
If, a function does not require any input to run, you can run it (.m file) by pressing the green button.
However, that is not the case with live function (.mlx file), for which you need to explicitly call it.
feynman feynman
feynman feynman 2024 年 2 月 27 日
thanks so much

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

採用された回答

Cris LaPierre
Cris LaPierre 2024 年 2 月 27 日
編集済み: Cris LaPierre 2024 年 2 月 27 日
Yes, MATLAB supports nested functions.However, you must call a function. You run a script.
To enable the Run button, at the very top of your live script, call your function.
sl
function sl
...
end
Note that the clear is unnecessary, as your function runs in tis own workspace. It will not have anything in it at this point.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by