Function Reference
— Built-in Function: ndims (a)

Returns the number of dimensions of array a. For any array, the result will always be larger than or equal to 2. Trailing singleton dimensions are not counted.