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:
dynamic input varargin

Subject: dynamic input varargin

From: kees de Kapper

Date: 7 Mar, 2013 14:40:11

Message: 1 of 4

Hi all,

I've got a question. I don't know if it is possible.

A normal function call is certainfunc(variable1, variable2, variable3)
But could I perform a construction as below?

> A = {variable1, variable2, variable3}
> certainfunc(A)
>
> function certainfunc(varargin)
> .
> some code over here
> .

How could I do something like this without an error message of "Not enough input arguments." or something else.

thanx,

Kees

Subject: dynamic input varargin

From: Steven_Lord

Date: 7 Mar, 2013 14:54:34

Message: 2 of 4



"kees de Kapper" <kees_de_kapper@hotmail.com> wrote in message
news:kha8sb$2f$1@newscl01ah.mathworks.com...
> Hi all,
>
> I've got a question. I don't know if it is possible.
>
> A normal function call is certainfunc(variable1, variable2, variable3)
> But could I perform a construction as below?
>
>> A = {variable1, variable2, variable3}
>> certainfunc(A)

You came very close to getting it right. You need to turn A into a
comma-separated list which will pass each cell in as a separate input
argument. This is pretty easy to do:

certainfunc(A{:})

*snip*

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: dynamic input varargin

From: Bruno Luong

Date: 7 Mar, 2013 14:55:07

Message: 3 of 4

"kees de Kapper" <kees_de_kapper@hotmail.com> wrote in message <kha8sb$2f$1@newscl01ah.mathworks.com>...
> Hi all,
>
> I've got a question. I don't know if it is possible.
>
> A normal function call is certainfunc(variable1, variable2, variable3)
> But could I perform a construction as below?
>
> > A = {variable1, variable2, variable3}
> > certainfunc(A)

Rather:

certainfunc(A{:})

Bruno

Subject: dynamic input varargin

From: kees de Kapper

Date: 9 Mar, 2013 13:10:09

Message: 4 of 4

Steve and Bruno Thank you very much!!

Kees


"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <kha9ob$36l$1@newscl01ah.mathworks.com>...
> "kees de Kapper" <kees_de_kapper@hotmail.com> wrote in message <kha8sb$2f$1@newscl01ah.mathworks.com>...
> > Hi all,
> >
> > I've got a question. I don't know if it is possible.
> >
> > A normal function call is certainfunc(variable1, variable2, variable3)
> > But could I perform a construction as below?
> >
> > > A = {variable1, variable2, variable3}
> > > certainfunc(A)
>
> Rather:
>
> certainfunc(A{:})
>
> Bruno

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