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:
Wrong function call

Subject: Wrong function call

From: ilias Papalaios

Date: 12 May, 2010 18:16:05

Message: 1 of 5

I have a question and i need help
I am writting the below:

function ReturnValue = ...
something('functioname',[0.5 0.5],10, 0.001, 0,1 ,10)


error : invalid syntax

What would be the right syntax?
Thank you in advance!

Subject: Wrong function call

From: Walter Roberson

Date: 12 May, 2010 18:38:50

Message: 2 of 5

ilias Papalaios wrote:
> I have a question and i need help
> I am writting the below:
>
> function ReturnValue = ...
> something('functioname',[0.5 0.5],10, 0.001, 0,1 ,10)
>
>
> error : invalid syntax
>
> What would be the right syntax?

Sorry unclear what you are trying to do. that is definitely not valid
for a 'function' statement!!

Subject: Wrong function call

From: Sean

Date: 12 May, 2010 18:42:04

Message: 3 of 5

"ilias Papalaios" <papalaios@gmail.com> wrote in message <hser95$4ej$1@fred.mathworks.com>...
> I have a question and i need help
> I am writting the below:
>
> function ReturnValue = ...
> something('functioname',[0.5 0.5],10, 0.001, 0,1 ,10)
>
>
> error : invalid syntax
>
> What would be the right syntax?
> Thank you in advance!

I don't completely understand what you have here; but if you are trying to call the function 'functioname' use @functioname

>>doc function
>>doc function_handle

Subject: Wrong function call

From: Steven Lord

Date: 12 May, 2010 19:09:42

Message: 4 of 5


"ilias Papalaios" <papalaios@gmail.com> wrote in message
news:hser95$4ej$1@fred.mathworks.com...
>I have a question and i need help
> I am writting the below:
>
> function ReturnValue = ...
> something('functioname',[0.5 0.5],10, 0.001, 0,1 ,10)
>
>
> error : invalid syntax
>
> What would be the right syntax?

That depends. Are you trying to _define_ a function or _call_ a function?

If you're defining a function, then the syntax needs to be:

function [listOfOutputArguments] = functionName(listOfInputArguments)

where listOfOutputArguments and listOfInputArguments are lists of variable
names (you can't use expressions, like x+1 or [0.5 0.5] or the like, as
input argument names.)

If you're calling a function, you don't use the FUNCTION keyword.

ReturnValue = something('functionName', [0.5 0.5], ...)

You might want to review the section on Scripts and Functions, which
includes examples of function definitions and function calls, in the
documentation.

http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2525.html

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f7-38085.html

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Wrong function call

From: ilias Papalaios

Date: 13 May, 2010 03:33:03

Message: 5 of 5

"Steven Lord"
>
> That depends. Are you trying to _define_ a function or _call_ a function?
>
> If you're defining a function, then the syntax needs to be:
>
> function [listOfOutputArguments] = functionName(listOfInputArguments)
>
> where listOfOutputArguments and listOfInputArguments are lists of variable
> names (you can't use expressions, like x+1 or [0.5 0.5] or the like, as
> input argument names.)
>
> If you're calling a function, you don't use the FUNCTION keyword.
>
> ReturnValue = something('functionName', [0.5 0.5], ...)
>
> You might want to review the section on Scripts and Functions, which
> includes examples of function definitions and function calls, in the
> documentation.

> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Steven you truly helped me, thanks.
I was trying to call a function.
I should have written, as you mentioned, the names of the variables and not expressions.
So I wrote another one m-file and i pass them from there.
Thanks for your quick response, really helpful

Tags for 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