Function Reference
— Function File: [s1, s2, ..., sN] = ind2sub (dims, ind)

Convert a linear index into 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