Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Average or mean value of array

`M = mean(A)`

`M = mean(A,'all')`

`M = mean(A,dim)`

`M = mean(A,vecdim)`

`M = mean(___,outtype)`

`M = mean(___,nanflag)`

`M = mean(`

returns
the mean of the elements
of `A`

)`A`

along the first array dimension whose size
does not equal 1.

If

`A`

is a vector, then`mean(A)`

returns the mean of the elements.If

`A`

is a matrix, then`mean(A)`

returns a row vector containing the mean of each column.If

`A`

is a multidimensional array, then`mean(A)`

operates along the first array dimension whose size does not equal 1, treating the elements as vectors. This dimension becomes`1`

while the sizes of all other dimensions remain the same.

`M = mean(___,`

returns
the mean with a specified data type, using any of the input arguments
in the previous syntaxes. `outtype`

)`outtype`

can be `'default'`

, `'double'`

,
or `'native'`

.