%% Smooth Data with Sample Points
% Create a vector of noisy data that corresponds to a time vector t. Smooth the data relative to the times in t, and plot the original data and the smoothed data.

x = 1:100;
A = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
t = datetime(2017,1,1,0,0,0) + hours(0:99);
B = smoothdata(A,'SamplePoints',t);
plot(t,A,'-o',t,B,'-x')
legend('Original Data','Smoothed Data')

% Copyright 2012 The MathWorks, Inc.