Thread Subject: reshape/squeeze for structs?

Subject: reshape/squeeze for structs?

From: David Doria

Date: 30 Sep, 2007 17:15:26

Message: 1 of 3

I simply want to count the number of 1's in a specific field
of a struct, like this

a(1).yesno=1;
a(2).yesno=1;
a(3).yesno=0;

if i lookat

a.yesno

i see there are two 1's and one 0.

how can i put these into a vector so i dont have to count in
a loop? Reshape and Squeeze are giving me grief because
this is a struct.

Thanks,

David

Subject: reshape/squeeze for structs?

From: Tony Fisher

Date: 30 Sep, 2007 17:54:18

Message: 2 of 3

How about?

ceri=[a.yesno] ?

"David Doria" <daviddoria@gmail.com> wrote in message
<fdolje$oiq$1@fred.mathworks.com>...
> I simply want to count the number of 1's in a specific
field
> of a struct, like this
>
> a(1).yesno=1;
> a(2).yesno=1;
> a(3).yesno=0;
>
> if i lookat
>
> a.yesno
>
> i see there are two 1's and one 0.
>
> how can i put these into a vector so i dont have to count
in
> a loop? Reshape and Squeeze are giving me grief because
> this is a struct.
>
> Thanks,
>
> David

Subject: reshape/squeeze for structs?

From: David Doria

Date: 1 Oct, 2007 12:41:12

Message: 3 of 3

wow... it's always so easy!

"Tony Fisher" <tonyfisher100@btinternet.com> wrote in
message <fdonsa$ld9$1@fred.mathworks.com>...
> How about?
>
> ceri=[a.yesno] ?
>
> "David Doria" <daviddoria@gmail.com> wrote in message
> <fdolje$oiq$1@fred.mathworks.com>...
> > I simply want to count the number of 1's in a specific
> field
> > of a struct, like this
> >
> > a(1).yesno=1;
> > a(2).yesno=1;
> > a(3).yesno=0;
> >
> > if i lookat
> >
> > a.yesno
> >
> > i see there are two 1's and one 0.
> >
> > how can i put these into a vector so i dont have to count
> in
> > a loop? Reshape and Squeeze are giving me grief because
> > this is a struct.
> >
> > Thanks,
> >
> > David
>

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com