You are on page 1of 3

\ CUBIC SPLINE

In this code, x and y are the sample data points. The csapi command constructs the cubic
spline interpolant in the form of a piecewise polynomial, which is stored in the variable pp.
The fnval command evaluates the interpolant at the query points xq, and the resulting values
are stored in yq. Finally, the plot command is used to plot the original data points and the
interpolant.
\LAGRANGE POLYNOMIAL

In this code, x and y are the sample data points. The for loop evaluates the Lagrange
interpolating polynomial at each query point xx(i), using the sample data points x and y. The
resulting values are stored in yy(i). Finally, the plot command is used to plot the original data
points and the interpolant.

PIECEWISE linear
In this code, x and y are the sample data points. The interp1 command constructs the
piecewise linear interpolant and evaluates it at the query points xx. The resulting values are
stored in yy. Finally, the plot command is used to plot the original data points and the
interpolant.

You might also like