Speed ​​improvements for sorted vector in MATLAB

What is the fastest way to find the index of a value in a sorted vector in MATLAB? That is, is there a quick find(vector == myNumber, 1, 'first') when the vector is sorted?

I have a large matrix (200,000 x 4) of locations, each of which has a unique integer identifier written in the first column. I want to find the correct location of a known identifier, but thousands of searches can find me a little.

+4
optimization matlab
source share
3 answers

If you use ismembc2, the loc output should provide you with what you need. See This for more details:

http://www.mathworks.com/support/solutions/en/data/1-9NIE1N/index.html?product=ML&solution=1-9NIE1N

+4
source share
+3
source share

I don't know if this is faster, but you can try

 result=vector(vector(:,1)==myNumber,:) 

result will contain 4 rows of elements for which the vector first column == myNumber

0
source share

All Articles