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 ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: get struct field including empty values
Posted: May 13, 2013 9:59 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"John " <> wrote in message
> dpb <> wrote in message <kmjn0s$hkl$>...
>> On 5/10/2013 3:47 PM, dpb wrote:
>> ...

>> > allData(allData.correct==1).FieldName
>> Or, of course, if you make the field 'correct' a logical instead of
>> numeric then you can dispense w/ the '==1' part and simply write
>> allData(allData.correct).FieldName
>> --

> Hey guys thanks for your responses.
> allData(allData.correct==1) does not work because allData.correct returns
> every value as a unique anser, the solution to this is
> allData([allData.correct==1]) but this raises the same problem as stated
> in my first post.
> The reason I allow empty values is in this case to differentiate between
> correct responses, incorrect responses, and no responses.

So you're looking for a ternary state and simulating this by using the
binary logical class plus empty. I'd probably switch this around and use 1
for correct answer, -1 for incorrect answer, and 0 for no answer. If you're
worried about an increase in memory consumption, use int8 instead of double.

CORRECT = int8(1);
INCORRECT = int8(-1);
NOANSWER = int8(0);
allData(1).correct = NOANSWER;
allData(1).correct == INCORRECT % false
allData(1).correct == NOANSWER % true

With this coding system, your concatenation-based syntax:


just works.

Steve Lord
To contact Technical Support use the Contact Us link on

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.