Learn R Programming

pracma (version 1.7.0)

pchip: Hermitean Interpolation Polynomials

Description

Piecewise Cubic Hermitean Interpolation Polynomials.

Usage

pchip(xi, yi, x)

Arguments

xi, yi
x- and y-coordinates of supporting nodes.
x
x-coordinates of interpolation points.

Value

  • Values of interpolated data at points x.

Details

pchip is a `shape-preserving' piecewise cubic Hermite polynomial approach that apptempts to determine slopes such that function values do not overshoot data values.

References

Moler, C. (2004). Numerical Computing with Matlab. Revised Reprint, SIAM.

See Also

interp1

Examples

Run this code
x <- c(1, 2, 3, 4, 5, 6)
y <- c(16, 18, 21, 17, 15, 12)
plot(x, y, col="red", xlim=c(0,7), ylim=c(10,22),
     main = "Spline and 'pchip' Interpolation Polynomials")
grid()

xs <- seq(1, 6, len=51)
ys <- interp1(x, y, xs, "spline")
lines(xs, ys, col="cyan")
yp <- pchip(x, y, xs)
lines(xs, yp, col = "magenta")

Run the code above in your browser using DataLab