M = mean(A) returnsthe average of the elementsof A follow me the very first array dimension whose sizedoes not equal 1.

You are watching: Matlab mean of array

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

If A is a matrix, climate mean(A) returnsa heat vector containing the average of each column.

If A is a multidimensional array,then mean(A) operates follow me the an initial array dimensionwhose size does not equal 1, dealing with the facets as vectors. Thisdimension becomes 1 if the size of all otherdimensions remain the same.

M = mean(A,"all") computes the mean over all facets of A. This syntax is valid for MATLAB® execution R2018b and also later.

M = mean(A,dim) returnsthe typical along measurement dim. For example, if A isa matrix, then mean(A,2) is a column vector containingthe median of each row.

M = mean(A,vecdim) computes the mean based on the dimensions specified in the vector vecdim. For example, if A is a matrix, climate mean(A,<1 2>) is the average of all elements in A, because every facet of a procession is included in the array slice identified by size 1 and also 2.

M = mean(___,outtype) returnsthe median with a stated data type, using any kind of of the intake argumentsin the previous syntaxes. Outtype deserve to be "default", "double",or "native".

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

Create a 4-by-2-by-3 selection of integers between 1 and also 10 and compute the mean values along the second dimension.

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 average over every dimensions of one array, you can either specify each dimension in the vector dimension argument, or use the "all" option.

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

Dimension to operate along, stated as a confident integer scalar. If no worth is specified, climate the default is the very first array dimension whose dimension does not equal 1.

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

Consider a two-dimensional input array, A.

mean returns A once dim isgreater 보다 ndims(A) or once size(A,dim) is 1.

Data Types: double | solitary | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Vector the dimensions, mentioned as a vector of optimistic integers. Each aspect represents a measurement of the intake array. The lengths the the output in the mentioned operating dimensions are 1, when the others continue to be the same.

Consider a 2-by-3-by-3 intake array, A. Climate mean(A,<1 2>) return a 1-by-1-by-3 variety whose elements are the method over each page of A.

See more: 22) Which Of The Three Spinal Meninges Is The Most Superficial To Deep?

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

Output data type, stated as "default", "double",or "native". This options also specify the datatype in which the procedure is performed.

outtypeOutput data type
"default"double, uneven the input data form is single, duration,or datetime, in i m sorry case, the calculation is "native"
"double"double, uneven the data kind is expression or datetime,in which case, "double" is not supported
"native"same data form as the input, uneven

Input data kind is logical, inwhich case, the output is double