Skip to content

MatrixQ

MatrixQ[expr] returns True if expr is a 2D matrix, False otherwise.

Attributes[MatrixQ] := {Protected}

Simple examples

In[1]:= MatrixQ[{}]
Out[1]= False
In[2]:= MatrixQ[{{}}]
Out[2]= True
In[3]:= MatrixQ[{{a}}]
Out[3]= True
In[4]:= MatrixQ[{{{}}}]
Out[4]= False
In[5]:= MatrixQ[{{{a}}}]
Out[5]= False
In[6]:= MatrixQ[{{a}, {b}}]
Out[6]= True
In[7]:= MatrixQ[{{a, b}, {c, d}}]
Out[7]= True
In[8]:= MatrixQ[{{a, b, e}, {c, d}}]
Out[8]= False
In[9]:= MatrixQ[{{a, b, e}, {c, d, f}}]
Out[9]= True
In[10]:= MatrixQ[{{{a}, {b}}, {{c}, {d}}}]
Out[10]= False
In[11]:= MatrixQ[{{a, b, e}}]
Out[11]= True