Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
function

Subject: function

From: K

Date: 12 Mar, 2010 00:35:21

Message: 1 of 2

Hi, I recently downloaded Matlab and have the following problem

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

Subject: function

From: Sadik

Date: 12 Mar, 2010 00:46:04

Message: 2 of 2

Hi,

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 " <kbhasi@gmail.com> wrote in message <hnc289$slr$1@fred.mathworks.com>...
> Hi, I recently downloaded Matlab and have the following problem
>
> 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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us