Convert vectors to indices
Syntax
ind = vec2ind(vec)
Description
ind2vec and vec2ind
allow indices to be represented either by themselves or as vectors containing a 1 in the row of the index they represent.
vec2ind(vec)
takes one argument,
vec
- Matrix of vectors, each containing a single 1.
and returns the indices of the 1's.
Examples
Here four vectors (containing only one 1 each) are defined and the indices of the 1's are found.
vec = [1 0 0 0; 0 0 1 0; 0 1 0 1]
ind = vec2ind(vec)
See Also
ind2vec
[ Previous | Help Desk ]