From: Conrad on
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
From: Matt Fig on
B = structfun(@(x) x.b,example) % Read the help for STRUCTFUN
From: Conrad on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <i0ml24$nhl$1(a)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!
From: us on
"Conrad " <conrad7(a)gmx.net> wrote in message <i0o4u1$f30$1(a)fred.mathworks.com>...
> "Matt Fig" <spamanon(a)yahoo.com> wrote in message <i0ml24$nhl$1(a)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
From: Matt Fig on
"us " <us(a)neurol.unizh.ch> wrote in message <i0ofbp$k62$1(a)fred.mathworks.com>...
> "Conrad " <conrad7(a)gmx.net> wrote in message <i0o4u1$f30$1(a)fred.mathworks.com>...
> > "Matt Fig" <spamanon(a)yahoo.com> wrote in message <i0ml24$nhl$1(a)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 ;-)