Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MATLAB Error: Function definitions are not permitted at the prompt or in scripts.

Status
Not open for further replies.

popat_panjaru

Full Member level 2
Joined
Mar 4, 2007
Messages
129
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,296
Activity points
2,248
hi to all

i m new learner in matlab so at the time of learning when i m trying to run any ready MATLAB program i always get one error msg like this

function hh = dtmfdesign(fcent, L, fs)
|
Error: Function definitions are not permitted at the prompt or in scripts.


so can anybody tell me what is it?..and how can i solve it?..

plz help me out..

Popatlal Panjarawala
 

Re: MATLAB Error

Hi,
In order to define the function you have to make a new .M file. In that way you can create the function and the call it from the command prompt.
 

Re: MATLAB Error

which kind of new .m file i have to create?..i cant able to understand what u r saying?...can u give me one short and sweet example for it????????
 

Re: MATLAB Error

here u go...

1.funtion should be made in new m-file
2. u can make m-file by clicking the top left file ->New -> M File.
3. the format of first line (other than comments) should be
function [output1,output2] = file_name(input1,input2)
3. type " help function" in matlan cmd prompt to get more help.
4. MOST IMP::::: name of file should be same as name of funcution name
e.g function [output] = test (input1)
here the name of the file SHOULD BE test.m or it will never work.
5. U can have as many outputs and inputs u want in the fields named output1 and input1.
6. One u made the function u can execute it by wirtting the name of fucntion on the command prompt with inputs
e.g test(1)
where " 1 " is the input data...


enjoy
 

Re: MATLAB Error

Also if the function you are defining needs a second cutom function if may be defined within the same .m file as the main function.

It should be noted though that the second function will not be accessable from withing matlab and only the first function will be able to use it. (see example)

function [o1,o2] = function1(in1,in2) %Main definition in .m file



function [avg] = average(input_vector) %Sub function only available to function1

Cheers
Slayer
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top