Navigation

Operators and Keywords

Function List:

C++ API

Function File: ind = sub2ind (dims, i, j)
Function File: ind = sub2ind (dims, s1, s2, …, sN)

Convert subscripts to a linear index.

The following example shows how to convert the two-dimensional index (2,3) of a 3-by-3 matrix to a linear index. The matrix is linearly indexed moving from one column to next, filling up all rows in each column.

linear_index = sub2ind ([3, 3], 2, 3)
⇒ 8

See also: ind2sub.

Package: octave