I have written a simple code that performs a 3-point moving average smoothing algorithm. It is supposed to follow the same algorithm as Matlab's smooth(...) function as described here.
However, the performance of my code is very different from that of Matlab. Matlab's 3-point filter appears to perform a much more aggressive smoothing. Why is that?
Here is my code:
NewSignal = signal;
for i = 2 : length(signal)-1
NewSignal(i,:) = (signal(i,:)+signal(i-1,:)+signal(i+1,:))./3;;
And here is how I called Matlab's function:
signal = smooth(time, signal, 3, 'moving');
And here is a comparison of the results:
As one can see, Matlab's function smooths the data a lot further. What is the reason for the discrepancy? How can I modify my code in order for it to perform more like the blue curve?
Any explanation would be greatly appreciated.
I am including the sample data which can be accessed through:
M = csvread('DS0009.csv');
time = M(:,1);
waveform = M(:,2);