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