Can I make a spline both smoothing *and* periodic?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Splines dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!