How can I fit a smooth curve to an arbitrary shape?

5 views (last 30 days)
I'm trying to simulate an airplane trajectory in 2D space and I need to smooth out some jagged corners that appear when I connect waypoints using ginput. The regular curve fitting tools don't seem to work since I'm not working with a one to one function. The x and y coordinates are parameterized with respect to time.
Is there any way that I can use matlab to automatically fit a smooth curve to the entire trajectory and return the coordinates of the new smoothed trajectory?
Any advice on this matter would be greatly appreciated.

Answers (1)

Walter Roberson
Walter Roberson on 11 Apr 2011
One approach to try would be to use a sliding window and replace each point by the centroid of the point and its nearest neighbours. Probably better, though, would be to weight by the distance to the other points -- for example if you do have a sharp corner at a distance from other points, you don't want it moved drastically.
Another approach would be to take the outline and smooth that. And I would suspect that some kind of erosion would work as well.
Another approach to consider is using a "snap to grid" processing of the ginput() values. Or see snapping afterwards, here

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!