interp1                package:signal                R Documentation

_I_n_t_e_r_p_o_l_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Interpolation methods, including linear, spline, and cubic
     interpolation.

_U_s_a_g_e:

     interp1(x, y, xi, method = c("linear", "nearest", "pchip", "cubic", "spline"), extrap = NA, ...)

_A_r_g_u_m_e_n_t_s:

     x,y: vectors giving the coordinates of the points to be
          interpolated. 

      xi: points at which to interpolate. 

  method: one of "linear", "nearest", "pchip", "cubic", "spline". 

  extrap: if 'TRUE' or ''extrap'', then extrapolate values beyond the
          endpoints. If 'extrap' is a number, replace values beyond the
          endpoints with that number (defaults to 'NA').  

     ...: for 'method='spline'', additional arguments passed to
          'splinefun'. 

_D_e_t_a_i_l_s:

     The following methods of interpolation are available:

     'nearest': return nearest neighbour

     'linear': linear interpolation from nearest neighbours

     'pchip': piece-wise cubic hermite interpolating polynomial

     'cubic': cubic interpolation from four nearest neighbours

     'spline': cubic spline interpolation-smooth first and second
     derivatives throughout the curve

_V_a_l_u_e:

     The interpolated signal, an array of 'length(xi)'.

_A_u_t_h_o_r(_s):

     Original Octave version by Paul Kienzle pkienzle@user.sf.net.
     Conversion to R by Tom Short.

_R_e_f_e_r_e_n_c_e_s:

     Octave Forge <URL: http://octave.sf.net>

_S_e_e _A_l_s_o:

     'approx', 'filter', 'resample', 'interp', 'spline'

_E_x_a_m_p_l_e_s:

     xf = linspace(0,11,500); yf = sin(2*pi*xf/5)
     #xp = c(0:1,3:10); yp = sin(2*pi*xp/5)
     xp = c(0:10); yp = sin(2*pi*xp/5)
     extrap = TRUE
     lin  = interp1(xp, yp, xf, 'linear', extrap = extrap)
     spl  = interp1(xp, yp, xf, 'spline', extrap = extrap)
     pch  = interp1(xp, yp, xf, 'pchip', extrap = extrap)
     cub  = interp1(xp, yp, xf, 'cubic', extrap = extrap)
     near = interp1(xp, yp, xf, 'nearest', extrap = extrap)
     plot(xp, yp, xlim=c(0,11))
     lines(xf, lin, col = "red")
     lines(xf, spl, col = "green")
     lines(xf, pch, col = "orange")
     lines(xf, cub, col = "blue")
     lines(xf, near, col = "purple")

