Hermite polynomial
[p, pdot, p2dot] = CL_hermiteFitPoly(xref, yref, ydotref)
Computes the Hermite polynomial passing through reference points.
The looked-for polynomial p must satisfy:
p(xref) = yref -> value
p'(xref) = ydotref -> derivative
Each column in xref, yref and ydotref define a different set of points. There are as many fits as there are columns, resulting in as many polynomials.
The (maximum) degree of the polynomial is equal to twice the number of rows in xref (or yref, or ydotref) minus 1.
The function also optionally returns the first and second derivative of the polynomial.
Note:
If the polynomial cannot be computed (because the abscissae are not all different) a constant polynomial equal to %nan is returned. The derivatives are then set to the same polynomial (%nan), which is not necessarily what the Scilab "derivat" function would do.
Reference abscissae. (PxN)
Corresponding ordinates. (PxN)
Corresponding derivatives. (PxN)
Hermite polynomials. (1xN)
First derivative of the polynomials. (1xN)
Second derivative of the polynomials. (1xN)
CNES - DCT/SB
// 1) Generate a polynomial (degree <= 5) xref = [-0.5; 0; 0.5]; yref = [1; 2; 3]; ydotref = [3; 2; 1]; [p, pdot] = CL_hermiteFitPoly(xref, yref, ydotref) // Check results horner(p, xref) // => yref horner(pdot, xref) // => ydotref // 2) Vectorized form (use previous result) xref = [[-0.5; 0; 0.5], [0; 0.5; 1]]; yref = horner(p, xref); ydotref = horner(pdot, xref); p2 = CL_hermiteFitPoly(xref, yref, ydotref) // Check results p2 - [p,p] // => [0,0] | ![]() | ![]() |