MATLAB Answers

Savitsky-Golay Filter Problem - Smoothing 3D line

8 views (last 30 days)
William on 22 Apr 2015
Commented: William on 23 Apr 2015
I wanted to smooth a 3d line using the Savitzky-Golay filter, but for this example is seems to not work properly. Any ideas why, and how to fix it?
% Savitzky–Golay filter (sgolayfilt) - smoothing individual axes
windowWidth = 27; %Standard example values
polynomialOrder = 3;
xsg=sgolayfilt(points(:,1),polynomialOrder, windowWidth);
ysg=sgolayfilt(points(:,2),polynomialOrder, windowWidth);
zsg=sgolayfilt(points(:,3),polynomialOrder, windowWidth);
xyzsg = [xsg,ysg,zsg];
hold on
hold off
Green crosses show the smoothed version - blue circles is the original data


Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 22 Apr 2015
How many elements are in your array? 27 looks like an incredibly wide window for your data. I would have used a width of 5 to 9 elements. Try that and see how it works out.


Show 9 older comments
William on 23 Apr 2015
Any idea how to avoid this? Seems to of missed 2 points and then jumps back to them from the top. -> perhaps just ignore last few points?
Image Analyst
Image Analyst on 23 Apr 2015
That did not happen with the data I used. Is that a new/different set of data?
William on 23 Apr 2015
yes - i've attached it to the previous post

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Translated by