# Piecewise Cubic Hermite Interpolating Polynomial (PCHIP)

6 views (last 30 days)
Bhomik Luthra on 14 Jun 2013
Hello friends
I am doing cubic interpolation for the data x = [5.8808 6.5137 7.1828 7.8953]; y = [31.2472 33.9977 36.7661 39.3567];
pp = pchip(x,y);
Now pp gives coefficients of the polynomials but why they are not satisfying the data points, I am not able to understand, why is it happening like that?
Thanks
Bhomik

Richard Brown on 14 Jun 2013
It works perfectly
x = [5.8808 6.5137 7.1828 7.8953];
y = [31.2472 33.9977 36.7661 39.3567];
pp = pchip(x,y);
You could draw a picture
xs = linspace(5, 8, 200);
ys = ppval(pp, xs);
plot(xs, ys, 'b-', x, y, 'ro')
Or test the function values
ppval(pp, x) - y
Where's the problem?
Bhomik Luthra on 14 Jun 2013
Hi Richard
I meant to say that if you try this command
x = [5.8808 6.5137 7.1828 7.8953];
y = [31.2472 33.9977 36.7661 39.3567];
pp = pchip(x,y)
and now see pp. It gives pp as
form: 'pp'
breaks: [5.8808 6.5137 7.1828 7.8953]
coefs: [3x4 double]
pieces: 3
order: 4
dim: 1
and pp.coefs are -0.0112 -0.1529 4.4472 31.2472
-0.3613 0.0884 4.2401 33.9977
-0.0422 -0.3028 3.8731 36.7661
I am not able to understand what these coefficients are? I think these are the polynomials representing the three intervals [5.8808:6.5137],[6.5137:7.1828],[7.1828:7.8953]
I tried to check the value of this fitting polynomial at the data points but it gives negative y values for second polynomial . Even third polynomial do not seem to satisfy the points.
I used these commands for obtaining the values
(for second polynomial)
xs = linspace(6.5137, 7.1828, 200);
y = polyval(pp.coefs(2,:),xs);
plot(xs,y)
I am trying this way because I wanted to find the area under the curve of the polynomials for my project, I am trying to obtain the functions and then integrating it over the x range.
But due to this issue, I think, these coefficients are not correct. If you know any other way to find the area of curve using your method, i.e. just by having the y values and x values, please let me know.
Thanks
Bhomik Luthra

### 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!