


ISVECTORD Returns the orientation of a 1-D vector.
ISVECTORD(VECT) is non-zero if exactly one dimension of VECT has
length greater than 1. The return value is then the index of that
dimension. Note that NDIMS can not be used to decide this question,
because it returns 2 for, e.g., (M x 1) and (1 x M) arrays.
Example:
isvectord(1); % returns 0
isvectord([1 2 ; 3 4]) % returns 0
isvectord([1:10]) % returns 2
See also ISVECTOR (Matlab R14 and later).

0001 function dim = isvectord(vect) 0002 %ISVECTORD Returns the orientation of a 1-D vector. 0003 % ISVECTORD(VECT) is non-zero if exactly one dimension of VECT has 0004 % length greater than 1. The return value is then the index of that 0005 % dimension. Note that NDIMS can not be used to decide this question, 0006 % because it returns 2 for, e.g., (M x 1) and (1 x M) arrays. 0007 % 0008 % Example: 0009 % isvectord(1); % returns 0 0010 % isvectord([1 2 ; 3 4]) % returns 0 0011 % isvectord([1:10]) % returns 2 0012 % 0013 % See also ISVECTOR (Matlab R14 and later). 0014 0015 nonsingle = (size(vect) > 1); 0016 dim = find(nonsingle); 0017 if ((length(dim)>1) || (isempty(dim))), dim = 0; end;