There is also a new feature introduced in MATLAB, starting in R2018b. if we have a matrix, then the mean(X,) will be the mean of all the elements present in A, because every element of the matrix A will be contained in the slice of the array defined by the dimensions 1 & 2 (As already mentioned, please do Remember that dimension 1 is for Rows and 2 is for columns) This function will calculate the mean on the basis of the dimensions specified in the vecdim vector. The dimension passed will be a scalar quantity. This function will result in the mean along the dimension dim. Here, since the dimension is not mentioned, the mean is taken along the row elements This dimension will become 1 and the size of other dimensions will not be changed. If X is a multidimensional array, mean(X) will operate along the 1st array dimension whose size is non-singleton (not equal to 1) and will treat all the elements as vectors.
mean(X) will return a row vector which will have mean of each column, if X is a matrix.mean(X) will return the mean of the elements, if X is a vector.
the size is not equal to 1 (It will consider the first dimension which is non-singleton).