Speed Enhancements for a Sorted Vector in MATLAB

matlab, optimization

Solution

If you use ismembc2, the loc output should give you 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

Problem

What is the fastest way to lookup the index of a value in sorted vector in MATLAB? That is, is there a fast `find(vector == myNumber, 1, 'first')` for when vector is sorted? I have a large matrix (200,000 x 4) of locations each with a unique integer ID recorded in the first column. I want to find the right the location of a known ID but thousands of searches can take me a little bit to find.

Original source

Related problems