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 Comments
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/57225-faster-way-of-writing-this-code-finding-index#comment_118690
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/57225-faster-way-of-writing-this-code-finding-index#comment_118690
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/57225-faster-way-of-writing-this-code-finding-index#comment_118693
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/57225-faster-way-of-writing-this-code-finding-index#comment_118693
Sign in to comment.