movmedian
Moving median
Syntax
Description
M = movmedian(
returns the
local A
,k
)k
-point median values, where each median 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 median is taken over only the elements
that fill the window. M
is the same size as
A
.
If
A
is a vector, thenmovmedian
operates along the length of the vectorA
.If
A
is a multidimensional array, thenmovmedian
operates along the first dimension ofA
whose size does not equal 1.If
A
is a table or timetable, thenmovmedian
operates along the variables ofA
. (since R2025a)
M = movmedian(___,
specifies the
dimension of dim
)A
to operate along for any of the previous syntaxes.
For example, if A
is a matrix, then
movmedian(A,k,2)
operates along the columns of
A
, computing the k
-element sliding median
for each row.
M = movmedian(___,
specifies
whether to include or omit nanflag
)NaN
values in A
.
For example, movmedian(A,k,"omitnan")
ignores
NaN
values when computing each median. By default,
movmedian
includes NaN
values.
M = movmedian(___,
specifies
additional parameters for the moving median using one or more name-value pair
arguments. For example, if Name,Value
)x
is a vector of time values, then
movmedian(A,k,"SamplePoints",x)
computes the moving median
relative to the times in x
.