Can I make a spline both smoothing *and* periodic?

4 次查看(过去 30 天)
Hi all,
I would like to make a smoothing spline through data, and enforce point and gradient equality at either end of my spline. Here's the data:
XYpts = [...
10 5 -5 -10 -5 0 10
0 9 9 0 -9 0 0];
figure, plot(XYpts(1,:), XYpts(2,:),'bo')
axis equal, grid on, hold on
And here I can do a smoothing spline without the constraints to make it periodic (note that it smooths the original data nicely, but meets a nasty sharp turn at the end):
dt = sum((diff(XYpts,[],2).^2));
t = cumsum([0,dt.^(0.25)]);
smoothingSpline = spaps(t,XYpts,1);
fnplt(smoothingSpline,'-r.')
And here I can do an interpolating spline with the correct continuity constraints I'm looking for:
interpolatingSpline = csape(t,XYpts,'periodic')
fnplt(interpolatingSpline,'-g.')
But neither of these do both at the same time (smooth the data and enforce continuity). Can you help?
The only way I can think of so far is a bit messy: repeat the starting/ending points of my data so that the smoothed spline wraps back over itself, and then only sample it within the "original" domain. Is there a better/cleaner way?
Thanks, Sven.

采纳的回答

Matt J
Matt J 2012-12-2
编辑:Matt J 2012-12-2
This FEX file advertises all kinds of convenient options for constraining spline fits,
You need the Optimization Toolbox, though.
  1 个评论
Sven
Sven 2012-12-3
Ha, thanks Matt, I actually had this toolbox, just never thought to apply it to 2d data.
The (minor) downside is that the fit needs to be applied separately to each X,Y channel, but it certainly fits the bill.
Thanks, Sven.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Splines 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by