Repetitious Binary Search
Version 1.0.1 (4,25 KB) von
Geoff Stanley
Binary search for the insertion index of a vector's elements in a matrix's columns, compatible with code generation
Perform a binary search to find the insertion index of
(a) a scalar in a vector
(b) each element of an array in a vector
(c) a scalar in each column of an array
(d) each element of an array in each column of an array.
The above arrays can be of arbitrary dimension, except in (d) where the number of elements in the first array must match the number of columns in the second array.
MATLAB's discretize function finds the insertion index of each element of a vector within a single 'edges' vector. This is generalized here to enable the 'edges' vector to be a matrix or higher dimensional array, giving a different 'edges' vector for each binary search problem.
These functions are compatible with MATLAB's code generation. Data is accessed in such a way that the MATLAB code is nearly as fast as its compiled version when run in MATLAB R2015b and later, thanks to the JIT compiler.
--- Future changes are unlikely, but if there are any they will be found on github, not here:
https://github.com/geoffstanley/neutral-surfaces/tree/master/lib/binsrch
Zitieren als
Geoff Stanley (2024). Repetitious Binary Search (https://www.mathworks.com/matlabcentral/fileexchange/70108-repetitious-binary-search), MATLAB Central File Exchange. Abgerufen.
Kompatibilität der MATLAB-Version
Erstellt mit
R2017b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS LinuxKategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und MATLAB Answers
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.0.1 | Update Description. No changes to files. |
||
1.0.0 |