Function definitions are not permitted in this context

15 ビュー (過去 30 日間)
LW
LW 2018 年 1 月 20 日
編集済み: Matt J 2018 年 1 月 20 日
Using Matlab R2017b, I can not define a function; I thought this was fixed in R2016b. Yes, I can define a script file.
>> function y = mydouble(x)
function y = mydouble(x)
Error: Function definitions are not permitted in this context.
  1 件のコメント
Greg
Greg 2018 年 1 月 20 日
編集済み: Greg 2018 年 1 月 20 日
You appear to be trying to define a function in the Command Window. That isn't going to work, and I don't think it counts as something that "needs to be fixed."
I assume you're referring to local functions in scripts for the R2016b bit. You need to be in the editor (Live or otherwise) to create a script, then add a function declaration at the end.

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

採用された回答

Matt J
Matt J 2018 年 1 月 20 日
編集済み: Matt J 2018 年 1 月 20 日
What was "fixed" is that you are now allowed to define local functions in scripts. However, you cannot define functions (except anonymous functions) at the command line.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by