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:
How many values does a function I'm trying to call return?

Subject: How many values does a function I'm trying to call return?

From: Misha Koshelev

Date: 23 Mar, 2010 19:29:22

Message: 1 of 4

Let's say I have a function handle. _OUTSIDE_ this function, I would like to determine whether:
i) the function has one (or more) output arguments, e.g.,
[a,b,c]=myfunc(d)
   blah
or
ii) the function has _no_ output arguments, e.g.,
myfunc(d)
   blah

It would be even better to know the _exact number_ of output arguments.

Mind you I would like to learn this _outside the function_ (my understanding is nargout etc are evaluated _within_ the function).

Much appreciate your help.

Thank you!

Misha

Subject: How many values does a function I'm trying to call return?

From: matt dash

Date: 23 Mar, 2010 19:39:05

Message: 2 of 4

"Misha Koshelev" <misha680@gmail.com> wrote in message <hob4qi$jsf$1@fred.mathworks.com>...
> Let's say I have a function handle. _OUTSIDE_ this function, I would like to determine whether:
> i) the function has one (or more) output arguments, e.g.,
> [a,b,c]=myfunc(d)
> blah
> or
> ii) the function has _no_ output arguments, e.g.,
> myfunc(d)
> blah
>
> It would be even better to know the _exact number_ of output arguments.
>
> Mind you I would like to learn this _outside the function_ (my understanding is nargout etc are evaluated _within_ the function).
>
> Much appreciate your help.
>
> Thank you!
>
> Misha


Did you even try using nargout....?

Subject: How many values does a function I'm trying to call return?

From: David Young

Date: 23 Mar, 2010 19:42:20

Message: 3 of 4

nargout works from outside the function - from the documentation:

"nargout(fun) returns the number of declared outputs for the function fun. If the function has a variable number of output arguments, nargout returns a negative value. fun may be the name of a function, or the name of Function Handles that map to specific functions."

Subject: How many values does a function I'm trying to call return?

From: Misha Koshelev

Date: 23 Mar, 2010 19:56:20

Message: 4 of 4

"David Young" <d.s.young.notthisbit@sussex.ac.uk> wrote in message <hob5is$3ik$1@fred.mathworks.com>...
> nargout works from outside the function - from the documentation:
>
> "nargout(fun) returns the number of declared outputs for the function fun. If the function has a variable number of output arguments, nargout returns a negative value. fun may be the name of a function, or the name of Function Handles that map to specific functions."

Oops my bad. You're right! Thanx

Misha

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