Note that there are some explanatory texts on larger screens.

plurals
  1. POPiecewise Cubic Hermite Interpolating Polynomial (PCHIP) for given data in MATLAB and then finding area
    primarykey
    data
    text
    <p><strong>Hello friends</strong> </p> <p>I am trying to do Piecewise Cubic Hermite Interpolation on the data given below in MATLAB and then I want to get the area covered by the polynomials with x axis. I think, I am misunderstanding the meaning of coefficients returned by pchip command, but not sure. Does anyonw know what could be the problem? </p> <pre><code>x = [5.8808 6.5137 7.1828 7.8953]; y = [31.2472 33.9977 36.7661 39.3567]; pp = pchip(x,y) </code></pre> <p>If I see see pp,it gives pp as</p> <pre><code> form: 'pp' breaks: [5.8808 6.5137 7.1828 7.8953] coefs: [3x4 double] pieces: 3 order: 4 dim: 1 </code></pre> <p>and pp.coefs are</p> <pre><code>-0.0112 -0.1529 4.4472 31.2472 -0.3613 0.0884 4.2401 33.9977 -0.0422 -0.3028 3.8731 36.7661 </code></pre> <p>I think these are the polynomials representing the three intervals</p> <pre><code>[5.8808:6.5137], [6.5137:7.1828], [7.1828:7.8953] </code></pre> <p>But when I find the y values corresponding to x values using these polynomials, it gives wrong values.</p> <p>It gives negative y values for second polynomial . Even third polynomial do not seem to satisfy the points.</p> <p>I used these commands for obtaining the values</p> <p>For example:- (for second polynomial)</p> <pre><code>xs = linspace(6.5137, 7.1828, 200); y = polyval(pp.coefs(2,:),xs); plot(xs,y) </code></pre> <p>I want to find the area under the curve covered by this plot, that's why I am trying to find the polynomial. Is there any other way to do it or if anyone could find the problem in the commands that I am using, please let me know.</p> <p><em>Thanks</em></p> <p><em><strong>Bhomik Luthra</em></strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload