is it possible to write a function inside a script?

is it possible to write a function inside a script? for example is it possible to put at the end of the script?

 采纳的回答

you can in MATLAB R2016b or later. functions in scripts

1 个评论

This has been discussed such frequently in this forum, that it got tedious. And now the answer has changed. Wow.

请先登录,再进行评论。

更多回答(2 个)

calling subfunctions: https://www.coursera.org/learn/matlab/lecture/9N7ZS/subfunctions

1 个评论

subfunctions are not relevant to the question of whether you can define a function inside a script.

请先登录,再进行评论。

Short answer: No.
Longer answer: Nnnnnooooo.
Not much else I can say.

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by