## Documentation Center |

Mean excluding outliers

`m = trimmean(X,percent)trimmean(X,percent,dim)m = trimmean(X,percent,flag)m = trimmean(x,percent,flag,dim)`

`m = trimmean(X,percent)` calculates
the trimmed mean of the values in `X`. For a vector
input, `m` is the mean of `X`, excluding
the highest and lowest `k` data values, where `k=n*(percent/100)/2` and
where `n` is the number of values in `X`.
For a matrix input, `m` is a row vector containing
the trimmed mean of each column of `X`. For `n`-D
arrays, `trimmean` operates along the first non-singleton
dimension. `percent` is a scalar between 0 and 100.

`trimmean(X,percent,dim)` takes
the trimmed mean along dimension `dim` of `X`.

`m = trimmean(X,percent,flag)` controls
how to trim when `k` is not an integer. `flag` can
be chosen from the following:

'round' | Round k to the nearest integer (round to
a smaller integer if k is a half integer). This
is the default. |

'floor' | Round k down to the next smaller integer. |

'weight' | If k=i+f where i is the
integer part and f is the fraction, compute a weighted
mean with weight (1-f) for the (i+1)th and (n-i)th values,
and full weight for the values between them. |

`m = trimmean(x,percent,flag,dim)` takes
the trimmed mean along dimension `dim` of `x`.

Was this topic helpful?