Next: , Previous: , Up: Octave Functions and Scripts   [Contents][Index]


5.51 ind2sub_tril

Function File: [ r, c ] = ind2sub_tril (N, idx)

Convert a linear index to subscripts of a trinagular matrix.

An example of trinagular matrix linearly indexed follows

         N = 4;
         A = -repmat (1:N,N,1);
         A += repmat (diagind, N,1) - A.';
         A = tril(A)
         => A =
             1    0    0    0
             2    5    0    0
             3    6    8    0
             4    7    9   10

The following example shows how to convert the linear index ‘6’ in the 4-by-4 matrix of the example into a subscript.

         [r, c] = ind2sub_tril (4, 6)
         => r =  2
           c =  3

when idx is a row or column matrix of linear indeces then r and c have the same shape as idx.

See also: vech, ind2sub, sub2ind_tril.