isvector

Tests whether the input is a vector.

Category: Language Fundamentals > Matrices and Arrays

Syntax

tf = isvector(A)

True when A is 1-by-n or n-by-1, in either orientation.

Description

A vector is a 2-D array with one dimension equal to 1, so isvector accepts rows and columns. Scalars count (they are 1-by-1), an empty [] does not, and an array like ones(1, 1, 3) is not a vector because it has three dimensions.

Input arguments

A
Any array.

Output arguments

tf
Logical scalar.

Example

isvector([1 2 3])
isvector([1; 2])
isvector([1 2; 3 4])
isvector([])
Output
ans = logical
   1
ans = logical
   1
ans = logical
   0
ans = logical
   0

See also

isrow iscolumn isscalar ismatrix