MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Evan
0

Faster way of writing this code: (finding index)

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 件のコメント

Roger Stafford
2012 年 12 月 22 日
Since the quantiles are in ascending order, it would likely be faster to use the 'histc' function with quantiles as the 'edges' vector and input as the first argument. The second returned argument (bin) would index the appropriate bin and thereby give you the index you seek.
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?

サインイン to comment.

2 件の回答

回答者: Loginatorist
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 件のコメント

Walter Roberson
2012 年 12 月 22 日
Because the values are in order, this is equivalent to returning the index of the last such value.
Loginatorist
2012 年 12 月 22 日
Yes, it will return the last value. How large is quantiles?

サインイン to comment.


回答者: Matt J
2012 年 12 月 23 日

  0 件のコメント

サインイン to comment.



Translated by