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: logical index in multi-dimensional arrary
Replies: 1   Last Post: Sep 16, 2013 4:37 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
jay cao

Posts: 2
Registered: 12/18/09
logical index in multi-dimensional arrary
Posted: Sep 14, 2013 10:55 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi all,

The following doesn't work. Why is it?

test = ones(2, 3, 2)
idx = [1, 0, 1; 0, 1, 0]
idx = logical(idx)
test(idx, 1)

the error from the last command is "Index exceeds matrix dimensions." It works if test is a 2-d array, i.e., the following works.

test = ones(2, 3)
idx = [1, 0, 1; 0, 1, 0]
idx = logical(idx)
test(idx)

why doesn't the logical index work in high dimensional array as in 2-d array? How can I get around with it, say i want to assign some values to test(idx, 1) where idx is a logical index 2-2 array.

Thanks.

Jay



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.