# movmean

Computes moving average values.

## Syntax

m=movmean(x)

m=movmean(x,wlen)

m=movmean(x,[nb,na])

m=movmean(...,dim)

m=movmean(...,dim,'Endpoints',v)

## Inputs

x
The data sample.
Type: double
Dimension: vector | matrix
wlen
The window length over which to compute means.
For odd values the window will be centered with respect to each target element. For even values there will be one more element before the target element than after.
Type: integer
Dimension: scalar
nb
The number of windowed points before the target element.
Type: integer
Dimension: scalar
na
The number of windowed points after the target element.
Type: integer
Dimension: scalar
dim
Dimension on which to perform the calculation.
Default: first non-singleton dimension.
Type: integer
Dimension: scalar
v
The 'Endpoints' property value.
The available options are as follows:
'shrink'
Windows that would extend beyond the matrix boundary shrink to contain only the existing data.
Windows that would extend beyond the matrix boundary are discarded with the result that the output dimensions are reduced.
'same'
Windows that would extend beyond the matrix boundary are filled with the values of the elements on the matrix boundary.
'periodic'
Windows that would extend beyond the matrix boundary are filled by wrapping around the other end of each dimension.
number
Windows that would extend beyond the matrix boundary are filled with a specified numeric value.

## Outputs

m
The moving mean results.
Dimension: vector | matrix

## Examples

Vector case:
x = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10];
m = movmean(x, 7)
m = [Matrix] 1 x 16
2.50000  2.60000  3.00000  3.14286  3.85714  4.14286  4.85714  5.14286  5.85714  6.14286  6.85714  7.14286  7.85714  8.00000  8.40000  8.50000
3D Matrix case with 'discard' option:
x = reshape([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10;
2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19]', 1, [], 2);
m = movmean(x, 7, 2, 'Endpoints', 'discard')
m =
slice(:, :, 1) =
[Matrix] 1 x 10
3.14286  3.85714  4.14286  4.85714  5.14286  5.85714  6.14286  6.85714  7.14286  7.85714

slice(:, :, 2) =
[Matrix] 1 x 10
5.85714  7.14286  7.85714  9.14286  9.85714  11.14286  11.85714  13.14286  13.85714  15.14286