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

New to MATLAB?

when defining functions on my matlab 7 version iam getting error!!!

Asked by mayuresh

mayuresh (view profile)

on 12 Jul 2012

??? function [f d] = add(x) | Error: Function definitions are not permitted at the prompt or in scripts.

0 Comments

mayuresh

mayuresh (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Jan Simon

Jan Simon (view profile)

on 12 Jul 2012
Edited by Jan Simon

Jan Simon (view profile)

on 12 Jul 2012
Accepted answer

The error message is clear: Functions can be defined inside M-files, when they are functions. You cannot create a function neither in M-scripts (M-files which does not start with "function ...", nor in the command window.

So open the editor to create a function. Then save the file to a user-defined folder, which is included in the path (see pathtool). (The later is not obligatory, but most likely what you want to.)

0 Comments

Jan Simon

Jan Simon (view profile)

Contact us