# sub2ind2

## PURPOSE

Improved version of sub2ind.

## SYNOPSIS

function ind = sub2ind2( siz, sub )

## DESCRIPTION

     Improved version of sub2ind.

     Almost the same as sub2ind, except always returns only a single output
     that contains all the subscript locations.  Also handles multiple linear
     subscripts at the same time more conveniently then matlab's version. See
     help for sub2ind for more info.

     USAGE
      ind = sub2ind2( siz, sub )

     INPUTS
      siz     - size of array into which sub is an index
      sub     - sub(i,:) is the ith set of subscripts into the array.

     OUTPUTS
      ind     - linear index (or vector of indicies) into given array

     EXAMPLE
      ind = sub2ind2( [10,10], [10 2] )      % 20
      ind = sub2ind2( [10,10], [9 2; 10 2] ) % 19, 20

     See also SUB2IND, IND2SUB2, SUBSTOARRAY

     Piotr's Image&Video Toolbox      Version 2.0
     Copyright 2008 Piotr Dollar.  [pdollar-at-caltech.edu]
     Please email me if you find bugs, or have suggestions or questions!
     Licensed under the Lesser GPL [see external/lgpl.txt]

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- modefilt1 One-dimensional mode filtering.
- subsToArray Converts subs/vals image representation to array representation.