Example of interpolation and extrapolation, MATLAB in Engineering

Assignment Help:

Example of Interpolation and extrapolation:

The MATLAB has a function to do this, known as polyfit. The function polyfit finds the coefficients of the polynomial of the particular degree which best fits the data by using a least squares algorithm. There are 3 arguments passed to the function: the vectors which represent the data, and the degree of the preferred polynomial. For illustration, to fit a straight line (degree 1) through the earlier data points, the call to the polyfit function would be:

>> polyfit(x,y,1)

ans =

   0.0000 67.6000

that says that the best straight line is of the form 0x + 67.6. Though, from the plot as shown in figure, it appears like a quadratic would be a much better fit. The following would generate the vectors and then fit a polynomial of degree 2 through the data points, storing the values in a vector known as coefs.

636_Example of Interpolation and extrapolation.png

>> x = 2:6;

>> y = [65 67 72 71 63];

>> coefs = polyfit(x,y,2)

coefs =

   -1.8571 14.8571 41.6000

This says that the MATLAB has determined that the best quadratic which fits these data points are:

-1.8571x2  + 14.8571x + 41.6. So, the variable coefs now stores a vector which represents this polynomial.


Related Discussions:- Example of interpolation and extrapolation

Sound files, Sound Files: The sound signal is an illustration of a con...

Sound Files: The sound signal is an illustration of a continuous signal which is sampled to result in a discrete signal. In this situation, sound waves traveling through the a

Gauss-jordan, Gauss-Jordan: The Gauss-Jordan elimination technique beg...

Gauss-Jordan: The Gauss-Jordan elimination technique begins in similar way which the Gauss elimination technique does, but then rather than of back-substitution, the eliminati

Illustration of gauss-jordan elimination, Illustration of gauss-jordan elim...

Illustration of gauss-jordan elimination: An illustration of interchanging rows would be r1 ¬→ r3, that would results: Now, beginning with this matrix, an illustration of sc

Execution steps - modular program, Execution steps: Whenever the progr...

Execution steps: Whenever the program is executed, the steps below will take place: The script calcandprintarea starts executing. The calcandprintarea calls the readr

Changing case, Changing Case: The MATLAB has two functions which conve...

Changing Case: The MATLAB has two functions which convert strings to all uppercase letters, or all lowercase, known as the upper and lower. >> mystring = 'AbCDEfgh';

Illustration of gauss-jordan, Illustration of gauss-jordan: Here's an ...

Illustration of gauss-jordan: Here's an illustration of performing such substitutions by using MATLAB >> a = [1 3 0; 2 1 3; 4 2 3] a = 1 3 0 2 1 3 4 2

Filter, A matlab function to calculate filter order

A matlab function to calculate filter order

Function numden, function numden: The function numden will return indi...

function numden: The function numden will return individually the numerator & denominator of a symbolic expression: >> sym(1/3 + 1/2) ans = 5/6 >> [n, d] =

Binary search, Binary Search: The binary search supposes that the vect...

Binary Search: The binary search supposes that the vector has been sorted first. The algorithm is just similar to the way it works whenever looking for a name in a phone direc

Illustration of image processing, Illustration of Image processing: Th...

Illustration of Image processing: This displays that there are 64 rows, or in another word, 64 colors, in this specific colormap. It also displays that the first five colors a

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd