You are here : matlabSignal Processingmedfilt1

medfilt1() - Signal Processing

medfilt1(x) applies a third-order one-dimensional median filter to the input vector, x.

The function considers the signal to be 0 beyond the endpoints.

The output, y, has the same length as x.


Syntax

    y = medfilt1(x)
    y = medfilt1(x,n)
    example

    y = medfilt1(___,nanflag,padding)
    example

    y = medfilt1(x,n,blksz,dim)
    y = medfilt1(x,n,[],dim)


Example

%Generate a sinusoidal signal sampled for 1 second at 100 Hz. Add a higher-frequency sinusoid to simulate noise.
fs = 100;
t = 0:1/fs:1;
x = sin(2*pi*t*3)+0.25*sin(2*pi*t*40);

%Use a 10th-order median filter to smooth the signal. Plot the result.
y = medfilt1(x,10);
plot(t,x,t,y)
legend('Original','Filtered')
legend('boxoff')


Output / Return Value


Limitations


Alternatives / See Also


Reference

http://in.mathworks.com/help/signal/ref/medfilt1.html