Linear interpolation
[y] = CL_interpLin(xref,yref,x)
Linear interpolation.
Given reference abscissae (xref) sorted in strictly increasing order and corresponding ordinates (yref), the function computes interpolated ordinates for the given abscissae (x).
Notes:
- y = %nan for values of x that are outside [xref(1),xref($)]
Reference abscissae, sorted in strictly increasing order (1xN)
Corresponding ordinates (PxN)
Abscissae, where to interpolate (1xM)
Interpolated values (PxM)
CNES - DCT/SB
// Example 1: Exact interpolation xref = 1:6; yref = [3*xref; -1+8*xref]; x = 0:0.5:4; [y] = CL_interpLin(xref, yref, x); y - [3*x; -1+8*x] // Example 2: Interpolation of sin and cos xref = linspace(0,1,101); yref = [sin(2*%pi*xref); cos(2*%pi*xref)]; x = linspace(0,1,1001); [y] = CL_interpLin(xref, yref, x); scf(); plot(x, y - [sin(2*%pi*x); cos(2*%pi*x)]); |