Initialization of an interpolator object
itrp = itrp_init(); itrp = itrp_init(type); itrp = itrp_init('lagrange', degree);
Interpolator type (default is cardinal spline). Can be 'linear', 'cspline' or 'lagrange'.
Degree of the polynomial for Lagrange interpolation
Interpolator object
This function will create an interpolator object, that can be used either on fixed interpolation points (then use the interpolator with the resample function) or inside a dynamic clock recovery process (use with clock_rec_init function).
Supported interpolation modes are the following:
Linear (type = 'linear'
) : Piecewise linear interpolation between each pair of known values (equivalent to Lagrange of degree 1)
Cardinal spline (type = 'cspline'
) : Piecewise third degree polynomial between each pair of known values. The polynomials computed here are Catmull-Rom cardinal splines (equivalent to Lagrange of degree 3).
Lagrange (type = 'lagrange'
) : Piecewise polynomial interpolation (the degree d is configurable) between each pair of known values. Each polynomial is computed according to the d+1 neareast known values.
Comparison of different interpolators with the Runge function
R = 10; // Interpolation ratio itrp = itrp_init('linear'); // Creation of the interpolator t1 = (-1:0.2:1)'; x1 = t1 .^ 2; // Before interpolation x2 = resample(x1,R,itrp); // After interpolation // Plotting plot(t1,x1,'sk'); t2 = (-1:(0.2/R):1)'; plot(t2,x2(1:length(t2)),'b-'); legend(['$t^2$','Linear interpolation']); | ![]() | ![]() |
Linear interpolation
You can also define your own interpolator object, and for it to be compatible with the other functions (resample, clock_rec_init), it should be a structure containing the following fields:
itrp.name:
name of the interpolator (string)itrp.nspl:
Number of input sample needed to compute one output sample. For example, for the piecewise linear interpolator, it is 2.itrp.delay:
Delay, in number of input samples, introduced by the interpolatoritrp.fun:
Interpolating function, which prototype should be: y = itrp_fun(x,mu,itrp)
,
where x are nspl input samples, mu is the fractionnal delay, itrp the interpolator object, and y the computed output sample.