Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: get struct field including empty values
Replies: 12   Last Post: May 13, 2013 9:59 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: get struct field including empty values
Posted: May 10, 2013 4:25 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"John " <john.wielenbroek@tivaro.nl> wrote in message
news:kmj4kc$emn$1@newscl01ah.mathworks.com...
> I have conducted an experiment and saved all trials as a structure with
> relevant parameters as fields.
>
> If I only want to use the correct trials, I am using:
> indices = find([allData.correct]==1);
>
> However, It is only now (that I am using this strucure with over 30'000
> trials that I discover that this works incorrectly when some of the field
> values are empty or not a number.
> Then length(allData.correct) < length(allData)


It works correctly. It doesn't work the way you expected. Those are two
different things.

x = [1 [] 3] % The result is a 2-element vector [1 3].

Normally concatenation like that requires all the quantities being
concatenated to have the same number of rows. For backwards compatibility,
if I remember correctly, concatenating with [] is exempt from that
requirement and the [] is squeezed out of the resulting vector. I requested
that the development staff work on getting that documented in an
easy-to-find location.

> How do I obtain an array of all the trials values of a specific field,
> which is representive with respect to the index number?


What does it mean for allData(17).correct to be empty or NaN? [I chose 17
arbitrarily.] Shouldn't allData(n).correct be required to ALWAYS contain
either true or false? I would likely make my code default to allData.correct
being false, then only if I validate that the data is correct should the
field be changed and it should only be changed to true.

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.