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:
nargin

Subject: nargin

From: Priya

Date: 1 Feb, 2010 08:28:05

Message: 1 of 5

can someone explain this function in a easy way. I read this function using help but it did not get into my mind.

Thnaks

Subject: nargin

From: TideMan

Date: 1 Feb, 2010 09:26:00

Message: 2 of 5

On Feb 1, 9:28 pm, "Priya " <priya.biom...@gmail.com> wrote:
> can someone explain this function in a easy way. I read this function using help but it did not get into my mind.
>
> Thnaks

nargin is the number of input parameters that are actually sent into a
function.
So, if you had a function b=func(a1,a2,a3)
and you called it like this:
b=func(10,1);
ie., with one input parameter omitted,
you could check in the function how many input parameters there were,
and perhaps set a default:
if nargin < 3
   a3=4;
end

There is also nargout, which works the same but on outputs.

Subject: nargin

From: Gavrilo Bozovic

Date: 1 Feb, 2010 09:30:28

Message: 3 of 5

"Priya " <priya.biomath@gmail.com> wrote in message <hk63al$2js$1@fred.mathworks.com>...
> can someone explain this function in a easy way. I read this function using help but it did not get into my mind.
>
> Thnaks

nargin indicates the number of inputs the user has supplied to a function.

I'm guessing the Matlab help says the same thing.

What is it you don't understand, specifically??

Subject: nargin

From: Priya

Date: 1 Feb, 2010 09:41:05

Message: 4 of 5



"Gavrilo Bozovic" <gavrilo.dot.bozovic@gmail.dot.ch> wrote in message <hk66vk$p70$1@fred.mathworks.com>...
> "Priya " <priya.biomath@gmail.com> wrote in message <hk63al$2js$1@fred.mathworks.com>...
> > can someone explain this function in a easy way. I read this function using help but it did not get into my mind.
> >
> > Thnaks
>
> nargin indicates the number of inputs the user has supplied to a function.
>
> I'm guessing the Matlab help says the same thing.
>
> What is it you don't understand, specifically??

Thanks everyone !!
 if its written nargin>2 what it means?

Subject: nargin

From: Jos (10584)

Date: 1 Feb, 2010 09:58:05

Message: 5 of 5

"Priya " <priya.biomath@gmail.com> wrote in message <hk67jh$49h$1@fred.mathworks.com>...

* SNIP ... nargin has been explained ...

> Thanks everyone !!
> if its written nargin>2 what it means?

?? You have just been explained what NARGIN means, so what is not clear here: still the word nargin, the symbol > or the number 2 ??

Try to translate it into words
"nargin > 2" means "this is true when the number of input arguments ..."

hth
Jos

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