movmad
Moving median absolute deviation
Syntax
Description
M = movmad(
returns an array of localA
,k
)k
-pointmedian absolute deviations (MADs), where each MAD is calculated over a sliding window of lengthk
across neighboring elements ofA
.M
is the same size asA
.
Whenk
is odd, the window is centered about the element in the current position. Whenk
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 MAD is taken over only the elements that fill the window.
If
A
is a vector, thenmovmad
operates along the length of the vectorA
.If
A
is a multidimensional array, thenmovmad
operates along the first dimension ofA
whose size does not equal 1.
M = movmad(___,
specifies the dimension ofdim
)A
to operate along for any of the previous syntaxes. For example,movmad(A,k,2)
for a matrixA
operates across the columns ofA
, computing thek
-element sliding MAD for each row.
M = movmad(___,
specifies whether to include or omitnanflag
)NaN
values from the calculation for any of the previous syntaxes.movmad(A,k,'includenan')
includes allNaN
values in the calculation, which is the default.movmad(A,k,'omitnan')
ignores them and computes the MAD over fewer points.
M = movmad(___,
specifies additional parameters for the moving MAD using one or more name-value pair arguments. For example, ifName,Value
)x
is a vector of time values, thenmovmad(A,k,'SamplePoints',x)
computes the moving MAD ofA
relative to the times inx
.