Faster way of writing this code: (finding index)

3 ビュー (過去 30 日間)
Evan
Evan 2012 年 12 月 22 日
The code I want to optimize is:
index_min = sum( input > quantiles );
where quantiles is a vector of doubles in increasing order. I am using the sum function to find the index of quantiles that corresponds to the value of input. I think the "find" function is actually slower.
  2 件のコメント
Image Analyst
Image Analyst 2012 年 12 月 22 日
編集済み: Image Analyst 2012 年 12 月 22 日
Just how much speed do you require? Is this for a real time app, like for video processing? How much slower? Are we talking nanoseconds here?

サインインしてコメントする。

回答 (2 件)

Matt Fig
Matt Fig 2012 年 12 月 22 日
That code does not return an index, but it does return the number of values in vector quantiles that are smaller than input.
  2 件のコメント
Matt Fig
Matt Fig 2012 年 12 月 22 日
Yes, it will return the last value. How large is quantiles?

サインインしてコメントする。


Matt J
Matt J 2012 年 12 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by