COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

Savitzky-Golay filtering and endpoint issues

• Email
• Follow

```I have successfully implemented Matlab's "sgolay" function to obtain
derivatives of noisy data, following the example documented in
Matlab's help for "sgolay".  Depending on the window size used for the
Savitzky-Golay filtering, a certain number of endpoints cannot be
dealt with since the window filter is not defined without the
requisite number of points that the filter spans.

If I were doing finite differencing, central differencing say, then
similar issues at the endpoints arise.  One can handle this by using
purely forward or backward schemes (of the same order) at the
endpoints to get derivatives.

My question for you is to how to handle the endpoints and get values
for derivatives, such that the results are in some sense consistent
with the Savitzky-Golay filtering and derivative calculations at the
interior points.  Is there is facility in the "sgolay" function for
handling the endpoints?  What's a principled way to do this in
general?  The example provided in the documentation does not address
this.

Thanks for any advice on the endpoints issue.

Jim
```
 0

See related articles to this posting

```Dear Jim,

there is not only a numerical problem for the definition of the derivative at the margins, it is a physical problem also. All methods to deal with the margins are more or less arbitrary and based on physical assumptions about the not recorded points.
E.g. the calculation of the speed of a car will fail, if the measurement stops exactly at the contact with a wall.
Therefore in my opinion a discussion about the best (or even a good) treatment of margins is purely academical, as long as the real physical system is not considered in the method.

FILTFILT has a nice reflection method, but it is not matching a Savitzky-Golay-filtering well.

Kind regards and good luck, Jan
```
 0