M = mean(A) returns
the mean value along the first array dimension of A whose
size does not equal 1.

If A is a vector, then mean(A) returns
the mean of the elements.

If A is a nonempty, nonvector matrix,
then mean(A) treats the columns of A as
vectors and returns a row vector whose elements are the mean of each
column.

If A is an empty 0-by-0 matrix,
then mean(A) returns NaN.

If A is a multidimensional array,
then mean(A) treats the values along the first
array dimension whose size does not equal 1 as vectors and returns
an array of row vectors. The size of this dimension becomes 1 while
the sizes of all other dimensions remain the same.

M = mean(A,dim) returns
the mean along dimension dim. For example, if A is
a matrix, then mean(A,2) is a column vector containing
the mean of each row.

M = mean(___,type) returns
the mean in the class specified by type, using
any of the input arguments in the previous syntaxes. type can
be 'double', 'native', or 'default'.

This operation produces a 1-by-1-by-4 array by computing the
mean of the three values along the second dimension. The size of the
second dimension is reduced to 1.

Compute the mean along the first dimension of A.

M = mean(A,1);
isequal(A,M)

ans =
1

This operation returns the same array as A because
the size of the first dimension is 1.

Dimension to operate along, specified as a positive integer
scalar. If no value is specified, the default is the first array dimension
whose size does not equal 1.

Dimension dim indicates the dimension whose
length reduces to 1. The size(M,dim) is 1,
while the sizes of all other dimensions remain the same.

Consider a two-dimensional input array, A.

If dim = 1, then mean(A,1) returns
a row vector containing the mean of the elements in each column.

If dim = 2, then mean(A,2) returns
a column vector containing the mean of the elements in each row.