# Numerical Techniques

Linear Interpolation

Linear interpolation can be performed with the interp1 function.

Cubic Spline Interpolation

A smoother curve can be created by using the cubic spline interpolation technique, included in the interp1 function.

Linear Regression

1. The simplest way to model a set of data is as a straight line.
2. To plot the data, draw a straight line through the data points to get a rough model of the data’s behavior.
3. This process is sometimes called “eyeballing it”—meaning that no calculations were done, but it looks like a good fit.
4. It is seen that several of the points appear to fall exactly on the line, but others are off by varying amounts.
5. In order to compare the quality of the fit of this line to other possible estimates, the difference between the actual
y-value and the value calculated from the estimate has found.
6. This difference is called the residual.
7. The linear regression technique uses an approach called least squares fit to compare how well different equations model the behavior of the data.
8. It is accomplished with the polyfit function.

Polynomial Regression

1. It is used to get the best fit by minimizing the sum of the squares of the deviations of the calculated values from the data.
2. The polyfit function allows to do this easily.

Polyval Function

1. The polyval function requires two inputs.
2. The first is a coefficient array, such as that created by polyfit.
3. The second is an array of input values for which output values are calculated.

Basic Fitting Tools

1. To activate the curve-fitting tools, select Tools : Basic Fitting from the menu bar in the figure.
2. The basic fitting window opens on top of the plot.
3. By checking linear, cubic, and show equations, the plot is generated.

Curve Fitting Toolbox

To open the curve-fitting toolbox, type cftool in the command window.