If I code a simple code on function, e.g. "function y=poly(x,a)"
Matlab gives me an error message
"Error: Function definitions are not permitted at the prompt or in scripts."
Can anyone please let me know as to what is happening?? Any help is deeply appreciated.
Thanks
You should start an m file [that is, a file with extension .m] with the keyword function, then you should have no problems at all.
The reason you are getting this error could be because:
1) You are typing this in the command window.
To avoid this, please type
edit newFunction
or some other name. This will open the Editor, where you will see a blank page to write whatever code you would like.
2) You have already opened the editor but after writing a few lines of code, you are typing the keyword function.
Hope this helps,
Best.
"K " <kbh...@gmail.com> wrote in message <hnc289$slr$1...@fred.mathworks.com>...