what does this error means-"Function definitions are not permitted at the prompt or in scripts."?
Mostrar comentarios más antiguos
i m getting this error in communication program
Respuesta aceptada
Más respuestas (2)
Meghana Dinesh
el 18 de Nov. de 2015
Editada: Meghana Dinesh
el 18 de Nov. de 2015
0 votos
It means you are trying to define a function in the prompt or maybe within a different script. This is not permitted in MATLAB. Define functions in their respective m-files (save the m-file with the same name as the function's). Read more about MATLAB functions .
5 comentarios
Walter Roberson
el 18 de Nov. de 2015
Lines that start with the word "function" cannot be used at the matlab prompt. They can only be used stored in files, and those files need to have either "function" or "classdef" as their first non-comment part.
EKTA DOGRA
el 18 de Nov. de 2015
Editada: Stephen23
el 18 de Nov. de 2015
It is not possible to mix the two: a file either is a script, or has functions, but cannot have both. I would recommend that you learn to write code using functions, which have many advantages over scripts.
- call a script by using the filename.
- call a function by using the function name.
EKTA DOGRA
el 18 de Nov. de 2015
EKTA DOGRA
el 20 de Nov. de 2015
Image Analyst
el 20 de Nov. de 2015
0 votos
Categorías
Más información sobre Language Support en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!