determine location of numbers within a vector

1 回表示 (過去 30 日間)
anton delehony
anton delehony 2015 年 11 月 20 日
回答済み: Thorsten 2015 年 11 月 20 日
Hi, I have a vector
x=[345 3433 20 5345 3533 21 3453453 34534 345345 22 234];
I'm looking for the fastest way to find the location of a numbers that starts from 20 and increase by one. In this toy example the output would be y=[3 6 10];
In reality the size of vector x for me can be 2 billion so I'm looking for a fast way to get y. Thanks for your suggestions.

回答 (1 件)

Thorsten
Thorsten 2015 年 11 月 20 日
ind = arrayfun(@(val) find(val == x), 20:22)

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by