<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
<MAN>
  <LANGUAGE>eng</LANGUAGE>
  <TITLE>sub2ind</TITLE>
  <TYPE>Scilab Function</TYPE>
  <DATE>20-Aug-2003</DATE>
  <SHORT_DESCRIPTION name="sub2ind">matrix  subscript values to linear index</SHORT_DESCRIPTION>
  <CALLING_SEQUENCE>
    <CALLING_SEQUENCE_ITEM>I = sub2ind(dims,i1,i2,...)</CALLING_SEQUENCE_ITEM>
    <CALLING_SEQUENCE_ITEM>J = sub2ind(dims,Mi)</CALLING_SEQUENCE_ITEM>
  </CALLING_SEQUENCE>
  <PARAM>
    <PARAM_INDENT>
      <PARAM_ITEM>
        <PARAM_NAME>dims</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: vector: the matrix dimensions</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>i1,i2,...</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: the subscript value arrays(same matrix shape as <VERB>I</VERB>)</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>Mi</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: matrix whose columns contains the subscript values.</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>I</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>:  the  linear index array</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
    </PARAM_INDENT>
  </PARAM>
  <DESCRIPTION>
    <P><VERB>sub2ind</VERB> is used to determine the equivalent single index
corresponding to a given set of subscript values.

<VERB>I = sub2ind(dims,i1,i2,..)</VERB> returns the linear index equivalent to the
row,  column, ... subscripts in the arrays <VERB>i1</VERB>, <VERB>i2</VERB>,..  for an matrix of
size <VERB>dims</VERB>. In this case <VERB>i1</VERB>, <VERB>i2</VERB>,.. must have the same shape and the
result <VERB>I</VERB> has the same matrix shape.

<VERB>I = sub2ind(dims,Mi)</VERB> returns the linear index
equivalent to the subscripts in the columns of the matrix <VERB>Mi</VERB> for a matrix
of size <VERB>dims</VERB>. in this case <VERB>I</VERB> is a column vector</P>
  </DESCRIPTION>
  <EXAMPLE>
<![CDATA[
i=[1 2 1 1 2 1 1];
j=[1 2 3 1 2 3 3];
k=[1 2 1 2 1 2 1];
sub2ind([2,3,2],i,j,k)

sub2ind([2,3,2],[i',j',k'])
</EXAMPLE>  ]]>
  </EXAMPLE>
  <SEE_ALSO>
    <SEE_ALSO_ITEM>
      <LINK>ind2sub</LINK>
    </SEE_ALSO_ITEM>
    <SEE_ALSO_ITEM>
      <LINK>extraction</LINK>
    </SEE_ALSO_ITEM>
    <SEE_ALSO_ITEM>
      <LINK>insertion</LINK>
    </SEE_ALSO_ITEM>
  </SEE_ALSO>
  <AUTHOR>
    Serge Steer, INRIA
  </AUTHOR>
</MAN>
