Note: This page has been translated by MathWorks. Click here to see

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

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

Moving standard deviation

`M = movstd(A,k)`

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

`M = movstd(___,w)`

`M = movstd(___,w,dim)`

`M = movstd(___,nanflag)`

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

`M = movstd(`

returns
an array of local `A`

,`k`

)`k`

-point standard deviation values. Each
standard deviation 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 standard deviation is taken over
only the elements that fill the window. `M`

is the
same size as `A`

.

If

`A`

is a vector, then`movstd`

operates along the length of the vector.If

`A`

is a multidimensional array, then`movstd`

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

`M = movstd(___,`

specifies
a normalization factor for any of the previous syntaxes. When `w`

)```
w
= 0
```

(default), `M`

is normalized by `k-1`

for
window length `k`

. When `w = 1`

, `M`

is
normalized by `k`

.

`M = movstd(___,`

returns
the array of sliding standard deviations along dimension `w`

,`dim`

)`dim`

for
any of the previous syntaxes. Always specify the weight `w`

from
the previous syntax when specifying `dim`

. For example, `movstd(A,k,0,2)`

operates
along the columns of a matrix `A`

, computing the `k`

-element
sliding standard deviation for each row. The normalization factor
is the default, `k-1`

.

`M = movstd(___,`

specifies
whether to include or omit `nanflag`

)`NaN`

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

includes
all `NaN`

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

ignores
them and computes the standard deviation over fewer points.

`M = movstd(___,`

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

)`x`

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

computes
the moving standard deviation relative to the times in `x`

.