MATLAB中排序向量的速度增强 [英] Speed Enhancements for a Sorted Vector in MATLAB
问题描述
在MATLAB中以排序向量查找值的索引的最快方法是什么?
也就是说,对向量进行排序时是否有快速的find(vector == myNumber, 1, 'first')
?
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?
我有一个很大的位置矩阵(200,000 x 4),每个位置在第一列中都有一个唯一的整数ID.我想找到一个已知ID的正确位置,但是成千上万次搜索可能会让我花点时间找到它.
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.
推荐答案
如果使用ismembc2,则loc输出应会为您提供所需的内容.有关更多详细信息,请参见此内容:
If you use ismembc2, the loc output should give you what you need. See this for more details:
这篇关于MATLAB中排序向量的速度增强的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!