I am looking at the Savitzky-Golay (SGOLAY) filters to try and remove anomalous spikes from experimental data. To do so, I need to ignore the anomalous point and want to use a Savitzky-Golay filter to approximate the new point value.
I found that the function rejected any weighting vector that had a zero element. Looking at the code, I do not understand why this restriction is necessary. Is this just an overly strict error message or does the algorithm break down in some way if a zero weighting is given to a point?
If I remove the error checking that checks for zeros in the SGOLAY and SGOLAYFILT functions, the results seem reasonable. Is there any reason why the error checking on line 45 of SGOLAYFILT is:
if min(W) <= 0, error('All the elements of the weight vector must be greater than zero.'), end
instead of:
if min(W) < 0, error('All the elements of the weight vector must be greater than zero.'), end
(Note the replacement of "<=" with "<")
Best Answer