Example: dental hygienist

ECE 1010 ECE Problem Solving I Interpolation and 6 Curve ...

ECE 1010 ECE Problem Solving IChapter 6: Overview6 1 Interpolation and Curve FittingOverviewGiven a set of data that results from an experiment (simulationbased or otherwise), or perhaps taken from a real-life physicalscenario, we assume there is some function that passesthrough the data points and perfectly represents the quantity ofinterest at all non-data points. With Interpolation we seek a func-tion that allows us to approximate such that functional val-ues between the original data set values may be determined(estimated).

ECE 1010 ECE Problem Solving I Chapter 6: Interpolation 6–6 • Use MATLAB’s interp1 function to estimate vehicle veloci-ties on the interval [0,5] seconds with resolution of 0.01 sec-

Tags:

  Problem, Solving, Interpolation, Ece problem solving i interpolation and

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of ECE 1010 ECE Problem Solving I Interpolation and 6 Curve ...

1 ECE 1010 ECE Problem Solving IChapter 6: Overview6 1 Interpolation and Curve FittingOverviewGiven a set of data that results from an experiment (simulationbased or otherwise), or perhaps taken from a real-life physicalscenario, we assume there is some function that passesthrough the data points and perfectly represents the quantity ofinterest at all non-data points. With Interpolation we seek a func-tion that allows us to approximate such that functional val-ues between the original data set values may be determined(estimated).

2 The interpolating function typically passes throughthe original data set. With Curve fitting we simply want a func-tion that is a good fit (typically a best fit in some sense) to theoriginal data points. With Curve fitting the approximating func-tion does not have to pass through the original data set. An example of Interpolation using spline functions and least-squares Curve fitting using a fifth degree polynomial is shownin the following figure The data set is a set of 10 random numbers generated using10*rand(1,10) Note that the spline Interpolation passes through the datapoints while the Curve fit does notfx()fx()6 ECE 1010 ECE Problem Solving IChapter 6.

3 Interpolation6 2 A higher degree polynomial would presumably give a bet-ter fitInterpolation The simplest type of Interpolation is linear Interpolation ,which simply connects each data point with a straight line The polynomial that links the data points together is of firstdegree, , a straight line012345678910024681012 Interpolation and Curve Fitting to Random NumbersxData Points Cubic Spline InterpolationLeast-Squares Poly Fit 5th DegreePolynomialECE 1010 ECE Problem Solving IChapter 6.

4 Interpolation6 3 A more exotic Interpolation scheme is to connect the datapoints using third degree or cubic polynomialsLinear Interpolation Given data points and , where We wish to estimate where using linear inter-polation The linear Interpolation function for functional valuesbetween a and c can be found using similar triangles or bysolving of system of two equations for two unknowns The slope intercept form for a line is( ) As boundary conditions we have that this line must passthrough the point pairs and fc()fa()ca>fb()bac,[] xyacfa()fc()LinearInterpolationFunctionb fb()y x +=yfx() x +==xac,[] ,afa(),()cfc(),()ECE 1010 ECE Problem Solving IChapter 6.

5 Interpolation6 4 Thus we can write( )( ) Now we solve for and by using ( ) to solve for andsubstituting this expression into ( )soor( ) With known we now solve for ( ) In summary, the linear Interpolation formula is to obtain for ( ) Note: With some algebraic manipulation we can get the equa-tion in the text which isfa() a +=fc() c += fc() c =fa() afc() c += fc()fa() ca -------------------------= fc()fc()fa() ca -------------------------c =fb()abc fb()fc()fa() ca -------------------------bfc()fc()fa() ca -------------------------c +=fb()fa()ba ca ------------fc()fa() []+=ECE 1010 ECE Problem Solving IChapter 6.

6 Interpolation6 5 Given a data set, we can perform linear Interpolation betweeneach pair of data points to any desired resolution using theMATLAB function interp1 Understanding how linear Interpolation works is still veryimportant if you are writing a custom algorithm or want tocheck the results of a MATLAB calculation The functiony_new = interp1(x,y,x_new, linear );returns a vector y_new of the same size as x_new The vectors x and y contain the raw data If the fourth function argument, linear , is omittedinterp1 defaults to linear Interpolation It is assumed that the x_new vector has the same mini-mum and maximum values as x, but in x_new the pointscan be spaced to any desired resolution The vector y_new contains the linearly interpolated val-ues corresponding to x_new, and of course will match theoriginal y vector values at the corresponding x valuesExample.

7 Suppose we have the following velocity versus timedata (a car accelerating from a rest position)Table : Car velocity dataTime, sVelocity, 1010 ECE Problem Solving IChapter 6: Interpolation6 6 Use MATLAB s interp1 function to estimate vehicle veloci-ties on the interval [0,5] seconds with resolution of sec-onds x = 0:5; y = [0 10 25 36 52 59]; x_new = 0:.01:5; y_new = interp1(x,y,x_new,'linear'); plot(x,y,'d') holdCurrent plot held plot(x_new,y_new) title('Velocity versus Time','fontsize',18) ylabel('Miles per Hour','fontsize',14) xlabel('Time, seconds','fontsize',14) legend('Data Points','Linear Interpolation ') To check the calculation suppose we wish to find , thatis the vehicle velocity at seconds Using ( ) we enter the data point values for one and twoseconds225336452559 Table : Car velocity data (Continued)Time, sVelocity, ()ECE 1010 ECE Problem Solving IChapter 6.

8 Interpolation6 7 Does MATLAB agree? y_new = interp1(x,y, ,'linear')y_new = %%% YES! If the y vector is composed of columns of data, all corre-sponding to a single x vector of data, the interp1 functionwill output a row vector for each value in the x_new ()2510 21 21 ------------------2 + versus TimeMiles per HourTime, secondsData Points Linear InterpolationECE 1010 ECE Problem Solving IChapter 6: Interpolation6 8 Cubic-Spline Interpolation As we can see from the previous example, linear interpola-tion produces a rather jagged result if the data points are notclosely spaced and don t lie in a straight line An improved Interpolation procedure is to replace the straightline connecting the data points with a third degree polyno-mial The third degree polynomial is of the form As with linear Interpolation a new set of coefficients mustbe used for each interval between the available data points This polynomial is known as a cubic spline function It is very special since the coefficients are

9 Chosen to give asmooth transition as we pass from one point and the next This smooth behavior is accomplished by computing thepolynomial coefficients for each interval using more thanjust the adjacent data points (recall linear interpolationuses just the interval end points to determine and ) The MATLAB function interp1 implements cubic splineinterpolation by simply changing the fourth argument from linear to spline Example: Repeat the vehicle velocity example, except now usecubic spline interpolationyfx() 3x3 +2x2 1x ++== ECE 1010 ECE Problem Solving IChapter 6: Interpolation6 9 x = 0:5; y = [0 10 25 36 52 59]; x_new = 0.

10 01:5; y_new = interp1(x,y,x_new,'spline'); plot(x,y,'d') legend off holdCurrent plot held plot(x_new,y_new) title('Velocity versus Time','fontsize',18) ylabel('Miles per Hour','fontsize',14) xlabel('Time, seconds','fontsize',14) legend('Data Points','Cubic Spline Interpolation ') versus TimeMiles per HourTime, secondsData Points Cubic Spline InterpolationECE 1010 ECE Problem Solving IChapter 6: Interpolation6 10 The interp1 function provides several other interpolationmodes as well help interp1 % A portion of the on-line help)YI = INTERP1(X,Y,XI,'method') specifies alternate meth-ods.


Related search queries