ismatrix

Tests whether the input is a 2-D array.

Category: Language Fundamentals > Matrices and Arrays

Syntax

tf = ismatrix(A)

True when A has exactly two dimensions.

Description

Every scalar, vector and ordinary matrix, empty or not, counts as a matrix. Only arrays with three or more dimensions fail the test (ndims(A) > 2). The name suggests a stricter check, so use isvector, isscalar or size when you need a particular shape.

Input arguments

A
Any array.

Output arguments

tf
Logical scalar.

Example

ismatrix(5)
ismatrix([1 2; 3 4])
ismatrix(ones(2, 3, 4))
Output
ans = logical
   1
ans = logical
   1
ans = logical
   0

See also

isvector isscalar ndims size