This document discusses polynomial interpolation and fitting methods in MATLAB. It provides examples of:
- Finding the roots of a polynomial using the roots() function.
- Using polyfit() to find the coefficients of a polynomial that fits a set of data points.
- Using interpl() to perform linear, spline, and piecewise cubic interpolation between data points.
- Creating mesh and surface plots by generating a grid in the x-y plane and calculating the z-values at each point.
13. p=polyfit(x,y,n)
here p=A vector of the co-efficients of
the polynomial that fits the
data
co-
x=A vector with the horizontal
ordinate of the data points
y= A vector with the vertical
co-ordinate of the data points
n=Degree of polynomial
14. Here,
‘nearest’ : returns the value of the
data point that is nearest to the
yi = interpl (x, y, xi, ‘method’) interpolated point
‘linear’ : uses linear spline
interpolation
‘spline’ : uses cubic spline
interpolation
yi = It is Interpolated value
‘pchip’ : uses piecewise cubic Hermite
interpolation
x = It is a vector with horizontal co-ordinate of the input data
points
y = It is a vector with vertical co-ordinate of the input data points
xi = Horizontal co-ordinate of the interpolation point
22. Mesh & Surface plots are created in three steps:
*create a grid in the x-y plane
*calculate the value of z at each point of the grid
*create the plot