%% Noise Suppression by Median Filtering
% 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')

% Copyright 2015 The MathWorks, Inc.