Got Questions? Get Answers.
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 structure reference: use of colon

Subject: Dynamic structure reference: use of colon

From: Conrad

Date: 3 Jul, 2010 03:34:04

Message: 1 of 5

Hi,
I have the following structure:
example.a1.b=1;
example.a22.b=2;
example.a333.b=3;
f={'a1','a22','a333'};

I'm trying to access the b field from each example:
a=example.(f{:}).b
Is there a way to do this?

Thank you

Subject: Dynamic structure reference: use of colon

From: Matt Fig

Date: 3 Jul, 2010 06:24:04

Message: 2 of 5

B = structfun(@(x) x.b,example) % Read the help for STRUCTFUN

Subject: Dynamic structure reference: use of colon

From: Conrad

Date: 3 Jul, 2010 20:01:05

Message: 3 of 5

"Matt Fig" <spamanon@yahoo.com> wrote in message <i0ml24$nhl$1@fred.mathworks.com>...
> B = structfun(@(x) x.b,example) % Read the help for STRUCTFUN

Thanks. Matlab is brillant and so is this newsgroup of course!

Subject: Dynamic structure reference: use of colon

From: us

Date: 3 Jul, 2010 22:59:05

Message: 4 of 5

"Conrad " <conrad7@gmx.net> wrote in message <i0o4u1$f30$1@fred.mathworks.com>...
> "Matt Fig" <spamanon@yahoo.com> wrote in message <i0ml24$nhl$1@fred.mathworks.com>...
> > B = structfun(@(x) x.b,example) % Read the help for STRUCTFUN
>
> Thanks. Matlab is brillant and so is this newsgroup of course!

nah... not this NG... MATT FIG... he's brilliant...

us

Subject: Dynamic structure reference: use of colon

From: Matt Fig

Date: 3 Jul, 2010 23:15:07

Message: 5 of 5

"us " <us@neurol.unizh.ch> wrote in message <i0ofbp$k62$1@fred.mathworks.com>...
> "Conrad " <conrad7@gmx.net> wrote in message <i0o4u1$f30$1@fred.mathworks.com>...
> > "Matt Fig" <spamanon@yahoo.com> wrote in message <i0ml24$nhl$1@fred.mathworks.com>...
> > > B = structfun(@(x) x.b,example) % Read the help for STRUCTFUN
> >
> > Thanks. Matlab is brillant and so is this newsgroup of course!
>
> nah... not this NG... MATT FIG... he's brilliant...
>
> us


LOL, if it wasn't for the abundant evidence to the contrary which has been permanently archived in old threads, I might agree with you ;-)

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