movmedian
Computes moving median values.
Syntax
m = movmedian(x,wlen)
m = movmedian(x,[nb,na])
m = movmedian(...,dim)
m = movmedian(...,'Endpoints',v)
m = movmedian(...,nancond)
Inputs
- x
- The data sample.
- wlen
- The window length over which to compute means.
- nb
- The number of windowed points before the target element.
- na
- The number of windowed points after the target element.
- dim
- Dimension on which to perform the calculation.
- v
- The 'Endpoints' property value.
- nancond
- The NaN handling flag.
Outputs
- m
Examples
Vector case:
x = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10];
m = movmedian(x, 7)
m = [Matrix] 1 x 16
2.50000 3.00000 3.00000 3.00000 4.00000 4.00000 5.00000 5.00000 6.00000 6.00000 7.00000 7.00000 8.00000 8.00000 8.00000 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 = movmedian(x, 7, 2, 'Endpoints', 'discard')
m =
slice(:, :, 1) =
[Matrix] 1 x 10
3 4 4 5 5 6 6 7 7 8
slice(:, :, 2) =
[Matrix] 1 x 10
6 7 8 9 10 11 12 13 14 15