Clear Filters
Clear Filters

Fitting a smoothing spline method

2 views (last 30 days)
vedesh Mohit
vedesh Mohit on 2 Apr 2018
Answered: William Smith on 3 Apr 2018
hey, I have a dataset x=[NaN 1 2 3 NaN NaN 4 7 9 NaN 8 28 8 ]; and I would to know how to fit a smoothing spline method to this data?

Answers (1)

William Smith
William Smith on 3 Apr 2018
spline takes data in the format ( known X's, known Y's, desired X's)
So, for example:
xfitted = spline(1:numel(x), x, desiredx);
plot(desired, xfitted);
That's just a simple cubic spline. See also 'pchip', which has the same API. Smoothing splines more formally have a 'pressure' to penalise excessive curvature. If you need them, they're in the Curve Fitting Toolbox.

Community Treasure Hunt

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

Start Hunting!