MATLAB中排序向量的速度增强 [英] Speed Enhancements for a Sorted Vector in MATLAB

查看:96
本文介绍了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:

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

这篇关于MATLAB中排序向量的速度增强的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆