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: efficient find row
Replies: 1   Last Post: Oct 13, 2011 8:03 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Andreas Lobinger

Posts: 12
Registered: 7/29/11
efficient find row
Posted: Oct 13, 2011 7:51 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hello,

i was wandering, if there is an efficient way to find rows equal to a certain vector in matrices.

My current approach (which varies) is something like this
r =

3 1 3
3 2 1
2 2 2
3 2 2

test_vector =
3 2 1
>> find(sum(bsxfun(@eq,test_vector,r),2) == 3)
2

so built an element specific test for all entries and then sum up the trues and
find within them.

It works and it's OK.

If you need to do this often, you built a lot of values not needed later on ->
the first non-equal already spoils the whole row.

Any idea?
Wishing a happy day,
Andreas



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.