필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Sven
Sven 2012년 12월 2일
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