idx=find_idx(xi, xgrid)
This function not only bin similarly to HISTC, but also returns the fractional position of data points within the binning interval.
It is equivalent to
interp1(xgrid,(1:length(xgrid)), xi)
but with the speed improvement up to 5 times.
Algorithm: dichotomy, complexity of m.log(n), where m isnumber of data points (xi) and n is number of bins (xgrid).
Few obvious examples of applications:
- binning step for more sophisticated interpolation schemes such as multi-dimensional spline or linear tensorial interpolations.
- Generate discrete random sequences with given probability distribution.
Cite As
Bruno Luong (2026). find_idx (https://www.mathworks.com/matlabcentral/fileexchange/23049-find_idx), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2008b
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Mathematics > Interpolation >
Find more on Interpolation in Help Center and MATLAB Answers
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
