%% Gaussian Filter
% Smooth a vector of noisy data with a Gaussian-weighted moving average filter.  Display the window length used by the filter.

x = 1:100;
A = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
[B, window] = smoothdata(A,'gaussian');
window

% Smooth the original data with a larger window of length 20.  Plot the smoothed data for both window lengths.

C = smoothdata(A,'gaussian',20);
plot(x,B,'-o',x,C,'-x')
legend('Small Window','Large Window')

% Copyright 2012 The MathWorks, Inc.