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

Interchange rows - gauss-jordan elimination, Interchange rows : for illust...

Interchange rows : for illustration interchanging rows ri and rj is written as

True color matrice - image processing, True color matrice: The true co...

True color matrice: The true color matrices are the other way to represent images. The true color matrices are 3-dimensional matrices. The first two coordinates are the coordi

Converting between the string and number types, Converting between the Stri...

Converting between the String and Number types: The MATLAB has many functions which convert numbers to strings in which each character element is a separate digit, and vice ve

Technique to create nested structures, Technique to create Nested structure...

Technique to create Nested structures: This technique is the most proficient. Though, the other technique is to build the nested structure one field at a time. As this is a ne

Plotting file data, Plotting File data: It is frequently essential to ...

Plotting File data: It is frequently essential to read data from a file and plot it. Generally, this entails knowing the format of the file. For illustration, let us suppose t

Program to examine exponential function, Write a program to examine exponen...

Write a program to examine exponential function: We will write a program to examine the value of e and the exponential function. It will be a menu-driven. The menu options wil

Creating the structure variables, Creating the structure Variables: Cr...

Creating the structure Variables: Creating a structure variable can be accomplished by simply storing the values in fields by using assignment statements, or by using the stru

Illustration of gauss elimination, Illustration of Gauss elimination: ...

Illustration of Gauss elimination: For illustration, for a 2 × 2 system, an augmented matrix be: Then, the EROs is applied to obtain the augmented matrix into an upper

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] =

Signal and system, . Generate the following signal, x(n)=1+cos((25*pi...

. Generate the following signal, x(n)=1+cos((25*pi*n)/100),0 Compute the DTFT of x[n] for w=0:0.01:2*pi Plot the Real part, imaginary part, the amplitude and phas

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