0
votes

I have two vectors x and y, and I fit them by a smoothing spline fit in matlab. I obtain this:

 form: 'pp'
    breaks: [15.5649 16.2041 17.0345 18.0489 20.1834 22.5540 24.5158 27.7881 32.5594 36.0827 40.5951]
     coefs: [10x4 double]
    pieces: 10
     order: 4
       dim: 1

I need to know the coefficients of the fit in order to reconstruct the fitted curve. How can I get this information?

1

1 Answers

0
votes

As mentioned by @A_C, you can obtain the coefficients from the coefs parameter. You should keep in mind that a spline fits a different polynomial to each region - in your case 10 regions.

As it is quite a lot of work to reconstruct the curve from the coefficients Matlab offers you the ppval function to do this:

x = [3 4 7 9];
y = [2 1 2 0.5];
xx = 0:0.1:10;

pp = spline(x,y);
yy = ppval(pp,xx);
plot(xx,yy);

Alternatively, if you only need to perform one interpolation, why not do it directly:

x = [3 4 7 9];
y = [2 1 2 0.5];
xx = 0:0.1:10;

yy = spline(x,y,xx);
plot(xx,yy);