Navigation

Operators and Keywords

Function List:

C++ API

Function File: [s1, s2, …, sN] = ind2sub (dims, ind)

Convert a linear index to subscripts.

The following example shows how to convert the linear index 8 in a 3-by-3 matrix into a subscript. The matrix is linearly indexed moving from one column to next, filling up all rows in each column.

[r, c] = ind2sub ([3, 3], 8)
   ⇒ r =  2
   ⇒ c =  3

See also: sub2ind.

Package: octave