- Scilab Online Help
- Elementary Functions
- Discrete mathematics
- Floating point
- Integer representation
- Trigonometry
- abs
- amell
- and
- &
- binomial
- bitand
- bitor
- bloc2exp
- bloc2ss
- cat
- cell2mat
- cellstr
- char
- cumprod
- cumsum
- delip
- diag
- diff
- dsearch
- exp
- eye
- flipdim
- gsort
- imag
- imult
- ind2sub
- intersect
- inttrap
- isdef
- isempty
- isequal
- isequalbitwise
- isreal
- isvector
- kron
- lex_sort
- linspace
- log
- log10
- log1p
- log2
- logm
- logspace
- lstsize
- max
- meshgrid
- min
- modulo
- ndgrid
- ndims
- nextpow2
- norm
- ones
- or
- |
- pen2ea
- permute
- pertrans
- prod
- rand
- real
- resize_matrix
- setdiff
- sign
- signm
- size
- solve
- sqrt
- sqrtm
- squarewave
- ssrand
- sub2ind
- sum
- sysconv
- sysdiag
- syslin
- toeplitz
- trfmod
- trianfml
- tril
- trisolve
- triu
- typeof
- union
- unique
- vectorfind
- zeros
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
sub2ind
matrix subscript values to linear index
Calling Sequence
I = sub2ind(dims,i1,i2,...) J = sub2ind(dims,Mi)
Arguments
- dims
vector: the matrix dimensions
- i1,i2,...
the subscript value arrays(same matrix shape as
I
)- Mi
matrix whose columns contains the subscript values.
- I
the linear index array
Description
sub2ind
is used to determine the equivalent
single index corresponding to a given set of subscript values. I
= sub2ind(dims,i1,i2,..)
returns the linear index equivalent to
the row, column, ... subscripts in the arrays i1
,
i2
,.. for an matrix of size dims
. In
this case i1
, i2
,.. must have the
same shape and the result I
has the same matrix shape.
I = sub2ind(dims,Mi)
returns the linear index
equivalent to the subscripts in the columns of the matrix
Mi
for a matrix of size dims
. in
this case I
is a column vector.
Examples
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'])
See Also
Authors
Serge Steer, INRIA
<< ssrand | Elementary Functions | sum >> |