Note: This page has been translated by MathWorks. Please click here

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

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

Average or mean value of fixed-point array

* c* = mean(

`a`

`c`

`a`

`dim`

computes
the mean value of the fixed-point array * c* = mean(

`a`

`a`

computes
the mean value of the fixed-point array * c* = mean(

`a`

`dim`

`a`

`dim`

`dim`

The input to the `mean`

function must be a
real-valued fixed-point array.

The fixed-point output array * c* has
the same

`numerictype`

properties as the fixed-point
input array `a`

`a`

`fimath`

, then it is used for intermediate
calculations. The output, `c`

`fimath`

.When * a* is an empty fixed-point array
(value =

`[]`

), the value of the output array is
zero.Compute the mean value along the first dimension (rows) of a fixed-point array.

x = fi([0 1 2; 3 4 5], 1, 32); % x is a signed FI object with a 32-bit word length % and a best-precision fraction length of 28-bits mx1 = mean(x,1)

Compute the mean value along the second dimension (columns) of a fixed-point array.

x = fi([0 1 2; 3 4 5], 1, 32); % x is a signed FI object with a 32-bit word length % and a best-precision fraction length of 28 bits mx2 = mean(x,2)

The general equation for computing the `mean`

of
an array * a*, across dimension

`dim`

sum(a,dim)/size(a,dim)

Because `size(a,dim)`

is always a positive
integer, the algorithm casts `size(a,dim)`

to an
unsigned 32-bit `fi`

object with a fraction length
of zero (`SizeA`

). The algorithm then computes the
mean of * a* according to the following equation,
where

`Tx`

represents the `numerictype`

properties
of the fixed-point input array `a`

c = Tx.divide(sum(a,dim), SizeA)

Was this topic helpful?