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.

Moving sum

`M = movsum(A,k)`

`M = movsum(A,[kb kf])`

`M = movsum(___,dim)`

`M = movsum(___,nanflag)`

`M = movsum(___,Name,Value)`

`M = movsum(`

returns
an array of local `A`

,`k`

)`k`

-point sums, where each sum
is calculated over a sliding window of length `k`

across
neighboring elements of `A`

. When `k`

is
odd, the window is centered about the element in the current position.
When `k`

is even, the window is centered about the
current and previous elements. The window size is automatically truncated
at the endpoints when there are not enough elements to fill the window.
When the window is truncated, the sum is taken over only the elements
that fill the window. `M`

is the same size as `A`

.

If

`A`

is a vector, then`movsum`

operates along the length of the vector.If

`A`

is a multidimensional array, then`movsum`

operates along the first array dimension whose size does not equal 1.

`M = movsum(___,`

returns
the array of sliding sums along dimension `dim`

)`dim`

for
any of the previous syntaxes. For example, if `A`

is
a matrix, then `movsum(A,k,2)`

operates along the
columns of `A`

, computing the `k`

-element
sliding sum for each row.

`M = movsum(___,`

specifies
whether to include or omit `nanflag`

)`NaN`

values from the
calculation for any of the previous syntaxes. `movsum(A,k,'includenan')`

includes
all `NaN`

values in the calculation while `movsum(A,k,'omitnan')`

ignores
them and computes the sum over fewer points.

`M = movsum(___,`

specifies
additional parameters for the sum using one or more name-value pair
arguments. For example, if `Name,Value`

)`x`

is a time vector,
then `movsum(A,k,'SamplePoints',x)`

computes the
moving sum of `A`

relative to the times in `x`

.

Was this topic helpful?