Example of interpolation and extrapolation, MATLAB in Engineering

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.

Posted Date: 10/22/2012 8:45:55 AM | Location : United States







Related Discussions:- Example of interpolation and extrapolation, Assignment Help, Ask Question on Example of interpolation and extrapolation, Get Answer, Expert's Help, Example of interpolation and extrapolation Discussions

Write discussion on Example of interpolation and extrapolation
Your posts are moderated
Related Questions
Passing Structures to Functions: The whole structure can be passed to a function, or separate fields can be passed. For illustration, here are the two distinct versions of a f

Referring to and Showing Cell Array Elements and Attributes: Just as with the other vectors, we can refer to individual elements of the cell arrays. The only difference is tha

Use of While loop: Here is an illustration of calling the function, passing 5000 for the value of the input argument high. >> factgthigh(5000) ans = 5040 The itera

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

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

Initializing the data structure - Function: Function is shown as:   >> printcylvols(cyls) Cylinder x has a volume of 169.6 Cylinder a has a volume of 100.5

i want to run 4 instances of my matlab code on 4 processor cores. im executing the job from head node. i created a parallel job and assigned number of workers. but i don''t get bac

Function strncmp: The function strncmp compares only the first n characters in the strings and ignores the rest. The initial two arguments are strings to compare, and third ar


Variable Scope: The scope of any of variable is the workspace in which it is valid. The workspace generated in the Command Window is known as the base workspace. As we know