Admin Production ni-theme
Current Publication

Spline

LabWindows/CVI

Spline

Advanced Analysis Library Only

AnalysisLibErrType Spline (double arrayX[], double arrayY[], ssize_t numberOfElements, double b1, double b2, double y2[]);

Purpose

Calculates the second derivatives used by the cubic spline interpolant, given a tabulated function of the form yi = f(xi) for i = 0, 1, . . ., numberOfElements – 1, with xi < xi + 1, and given the boundary conditions firstBoundary and secondBoundary such that the interpolant's second derivative matches the specified values at x0 and xn – 1.

You can use this array with SpInterp to calculate an interpolation value.

Example Code

/* Choose ascending X-values. Pick corresponding Y-values randomly. Set boundary conditions and specify the cubic spline interpolant to run through the points. */
double X[100], Y[100], Y2[100], b1, b2;
int n, i;
n = 100;
for(i=0; i<n; i++)
X[i] = i * 0.1;
WhiteNoise (n, 5.0, 17, Y);
b1=0.0;
b2=0.0;
Spline (X, Y, n, b1, b2, Y2);

Parameters

Input
Name Type Description
arrayX double [] The known x-values for the planar function; these values must be in ascending order.
arrayY double [] The known y-values for the planar function.
numberOfElements ssize_t Number of elements in arrayX, arrayY, and secondDerivatives.
firstBoundary double The value of the first derivative of the interpolant at the first element of arrayX.
secondBoundary double The value of the first derivative of the interpolant at the last element of arrayX.
secondDerivatives double [] Array of second derivatives that specify the interpolant.

You can use this array with SpInterp to calculate an interpolation value.

These second derivatives represent the continuously differentiable curve to run though the n points (xi, yi).

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later

Example

Refer to analysis\interp.cws for an example of using the Spline function.