medfilt1
Applies a moving median filter in one dimension.
Syntax
m = medfilt1(x,n)
m = medfilt1(x,n,[],dim)
m = medfilt1(...,NaN_flag,padding)
Inputs
- x
- The data sample.
- n
- The window length over which to compute means.
- dim
- Dimension on which to perform the calculation.
- NaN_flag
- The NaN handling flag.
- padding
- The padding option.
Outputs
- m
Examples
Vector case:
x = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10];
m = medfilt1(x, 7)
m = [Matrix] 1 x 16
1 2 3 3 4 4 5 5 6 6 7 7 8 8 8 7
3D Matrix case:
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 = medfilt1(x, 7, [], 2)
m =
slice(:, :, 1) =
[Matrix] 1 x 16
1 2 3 3 4 4 5 5 6 6 7 7 8 8 8 7
slice(:, :, 2) =
[Matrix] 1 x 16
2 4 5 6 7 8 9 10 11 12 13 14 15 15 15 14