Skip to content

lookup

Approximate-match lookup in a vector or array.

v = lookup(lookup_value, lookup_vector, result_vector)
v = lookup(lookup_value, array)

Vector form: searches lookup_vector for the largest value ≤ lookup_value and returns the corresponding entry of result_vector. Both vectors must be sorted ascending.

Array form: searches the first row or column of array (depending on shape) and returns from the last row or column. Largely superseded by xlookup.

lookup(4.5, [1 3 5 7 9], ['a' 'b' 'c' 'd' 'e']) % 'b'
  • xlookup — Modern lookup with optional default and search direction.
  • vlookup — Vertical lookup in a table.
  • hlookup — Horizontal lookup in a table.
  • match — Position of a value in a vector.