smallest n such that vector(n) < a
古いコメントを表示
hi,
is there a efficient way that given a vector "vec" whose elements are monotonic increasing i can find the smallest index such that vec(n) < a. where "a" is some given value.
1 件のコメント
Image Analyst
2012 年 12 月 21 日
編集済み: Image Analyst
2012 年 12 月 21 日
The smallest/lowest/first index will be the first one (index = 1) like Azzi said. But that is a trivial case and I think you actually mean the highest index, and that is what Wayne gave you code for. Like m = [11 12 13 14 15] and the value = 13.1. The lowest index where m < 13.1 is 1 and the highest is 3. Please confirm/clarify.
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2012 年 12 月 21 日
編集済み: Azzi Abdelmalek
2012 年 12 月 21 日
v=[10 12 4 5 9 20]
idx=find(v<5,1)
1 件のコメント
Azzi Abdelmalek
2012 年 12 月 21 日
If v is increasing, the first index, if it exist, must be 1
カテゴリ
ヘルプ センター および File Exchange で Time-Frequency Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!