Function definitions are not permitted in this context

14 visualizaciones (últimos 30 días)
LW
LW el 20 de En. de 2018
Editada: Matt J el 20 de En. de 2018
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 comentario
Greg
Greg el 20 de En. de 2018
Editada: Greg el 20 de En. de 2018
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.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 20 de En. de 2018
Editada: Matt J el 20 de En. de 2018
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.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by