


ISVECTOR True for 1-D arrays.
ISVECTOR(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:
isavector(1); % returns 0
isavector([1 2 ; 3 4]) % returns 0
isavector([1:10]) % returns 2

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