The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

Posts: 9,850
Registered: 6/7/07
Re: get struct field including empty values
Posted: May 10, 2013 4:47 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 5/10/2013 12:11 PM, dpb wrote:
> On 5/10/2013 10:44 AM, John wrote:

>> 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)
>> How do I obtain an array of all the trials values of a specific field,
>> which is representive with respect to the index number?

> The index returned by find() will still be representative of the actual
> position; it simply is condition by the logical expression you have used
> in the search to (correctly) not return values that don't match the
> condition.
> If you want all members of a field, then don't put a conditional test on
> it; simply
> x=allData.xVarFieldName;
> And, of course, you don't need the new variable necessarily, just
> reference what you want.
> If that doesn't suit, post more details of why there was any question on
> this to begin with as I'm somewhat puzzled by what seems to be obvious...

What came to me later and while reading Steven's response which covers
another aspect very well is that maybe what you're looking for is
"logical addressing" so that the length is still full length if needed
for consonance w/ another operation but is still only operating on the
desired elements.

If that's it, instead of find() use



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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.