Skip to content

isvector

Test whether the input is a vector (one row or one column).

tf = isvector(A)

Returns true when A has at most one dimension whose size is greater than 1 — that is, when A is 1×N, N×1, or a scalar. A 0×0 empty matrix returns false.

isvector([1 2 3]) % 1
isvector([1;2;3]) % 1
isvector(magic(3)) % 0
isvector(7) % 1 (scalar is a vector of length 1)
  • isscalar — Test whether the input is a 1×1 scalar.
  • isempty — Test whether the input has zero elements.
  • size — Sizes along all dimensions, or along one specific dimension.
  • ndims — Number of dimensions of the input.