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 CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by