FUNCTION REFERENCE

sub2ind

Convert row/column subscripts to linear indices.

Convert row/column subscripts to linear indices.

Syntax

ind = sub2ind(siz, I, J)

Syntax

ind = sub2ind(siz, I1, I2, ..., In)

siz is a vector of at least two positive integers. All subscript arrays need the same size.

With fewer subscripts than dimensions the last one spans the remaining dimensions.

As in MATLAB only subscripts below 1 or above the dimension are rejected: 1.5 and NaN

pass through the arithmetic (sub2ind([3 4], 1.5, 1) is 1.5).

Example

sub2ind([3 4], 2, 3)   % 8

Differences from MATLAB: subscripts are numeric or logical double values only

(no integer classes).

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.