M = mean(A) returnsthe suppose of the elementsof A alengthy the initially selection dimension whose sizedoes not equal 1.

You are watching: Matlab average of array


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

If A is a matrix, then mean(A) returnsa row vector containing the mean of each column.

If A is a multidimensional range,then mean(A) operates alengthy the first selection dimensionwhose dimension does not equal 1, dealing with the facets as vectors. Thisdimension becomes 1 while the sizes of all otherdimensions remajor the exact same.


M = mean(A,"all") computes the mean over all aspects of A. This syntaxes is valid for MATLAB® versions R2018b and later.


M = mean(A,dim) returnsthe suppose alengthy dimension dim. For example, if A isa matrix, then mean(A,2) is a column vector containingthe suppose of each row.


M = mean(A,vecdim) computes the expect based on the dimensions specified in the vector vecdim. For example, if A is a matrix, then mean(A,<1 2>) is the suppose of all aspects in A, considering that eexceptionally facet of a matrix is had in the array slice identified by dimensions 1 and 2.


M = mean(___,outtype) returnsthe suppose with a mentioned data kind, using any kind of of the input argumentsin the previous syntaxes. outkind can be "default", "double",or "native".


M = mean(___,nanflag) specifieswhether to encompass or omit NaN worths from thecalculation for any kind of of the previous syntaxes. mean(A,"includenan") includesall NaN worths in the calculation while mean(A,"omitnan") ignoresthem.


Create a 4-by-2-by-3 array of integers between 1 and also 10 and compute the intend worths along the second measurement.


M = M(:,:,1) = 8.0000 5.5000 2.5000 8.0000M(:,:,2) = 10.0000 7.5000 5.5000 6.0000M(:,:,3) = 6.0000 5.5000 8.5000 10.0000
Starting in R2018b, to compute the intend over all dimensions of an selection, you can either specify each measurement in the vector measurement debate, or usage the "all" choice.


File Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | datetime | duration


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

Dimension dim suggests the dimension whoselength reduces to 1. The size(M,dim) is 1,while the sizes of all other dimensions reprimary the same.

Consider a two-dimensional input range, A.


*


*


mean returns A as soon as dim isgreater than ndims(A) or when size(A,dim) is 1.

File Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64


Vector of dimensions, specified as a vector of positive integers. Each facet represents a dimension of the input array. The lengths of the output in the mentioned operating dimensions are 1, while the others remain the exact same.

Consider a 2-by-3-by-3 input array, A. Then mean(A,<1 2>) returns a 1-by-1-by-3 selection whose aspects are the means over each web page of A.

See more: " Keeping Up Appearances Season 5 Episode 9, Keeping Up Appearances: Season 5 Episode 9

*

Documents Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64


Output data form, stated as "default", "double",or "native". These options likewise specify the datatype in which the operation is percreated.


outtypeOutput data type
"default"double, unless the input data kind is single, duration,or datetime, in which case, the output is "native"
"double"double, unmuch less the data kind is duration or datetime,in which instance, "double" is not supported
"native"very same data kind as the input, unmuch less

Input data form is logical, inwhich instance, the output is double