Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



efficient find row
Posted:
Oct 13, 2011 7:51 AM


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 nonequal already spoils the whole row.
Any idea? Wishing a happy day, Andreas



