How to get the value of slopes of pchip at the enpoints?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
David Gillcrist
el 7 de En. de 2024
Comentada: David Gillcrist
el 8 de En. de 2024
I'm using pchip to interpolate a set of data X. After getting the interpolation, I'm trying to have functions g and f, connect to the endpoints of the interpolation. I want g and f to have the same slopes where they connect to the endpoints. Is there a convenient way to get the values of the slopes of the pchip interpolation?
0 comentarios
Respuesta aceptada
Paul
el 7 de En. de 2024
The doc page pchip (under the Output Arguments, pp section) shows how the interpolationg polynominal is formed for each interval based on the breakpoints and the pp coefficients, from which it should be straighforward to compute the derivative at the leading and trailing edges of the first and last intervals respectively.
x = 0:.1:1;y=sin(x);
pp = pchip(x,y);
pp
Not sure why pp.oder = 4. That seems odd for a cubic polynomial.
Más respuestas (1)
Matt J
el 7 de En. de 2024
Editada: Matt J
el 7 de En. de 2024
You don't need to determine the end slopes to extrapolate X. Just use the 'extrap' option to obtain values where desired outside the boundaries of X.
You could also do a finite-difference approximation, e.g.,
x=sort(rand(1,10)); y=rand(size(x)); f=@(z) interp1(x,y,z,'pchip','extrap');
ye=y(end); delta=eps(ye);
endslope = ( f(ye+delta) - f(ye) )/delta
0 comentarios
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!