__lookup__
- :
idx =__lookup__(table, y)¶ - :
idx =__lookup__(table, y, opt)¶ Locate each entry of y within the sorted table table by binary search, returning for every element the index idx of its bracketing position.
table is treated as sorted; whether it ascends or descends is decided from its first and last entries, and the comparisons flip accordingly. With an ascending table the default result
idx(i)is the number of entries that do not exceedy(i), sotable(idx(i)) <= y(i) < table(idx(i)+1)holds for interior values. A value below the whole table gives 0 and a value at or above the end givesnumel (table). Besides numeric data, table may be a sorted cell array of strings matched lexicographically, in which case y is a string or cell array of strings.The optional third argument opt is a string of flag characters that may be combined:
"l"Clamp the lower end: a value that falls before the first entry reports index 1 instead of 0.
"r"Clamp the upper end: a value at or past the last entry reports
numel (table) - 1instead ofnumel (table). Supplying both"l"and"r"keeps every result inside[1, numel (table) - 1], picking a usable interval index for piecewise interpolation."m"Return a membership index: the position of an exact match in table, or 0 when the value is not present.
"b"Return a logical array that is
truewherever the corresponding value occurs exactly in table.