This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 14:440:127 Introduction to Computers for Engineers Notes for Lecture 10 Rutgers University, Fall 2008 Instructor Blase E. Ur Dont forget that Exam 2 runs 11/5  11/11. 4 written(20min), 4 computer(60min) Also, note that were going slightly out of order from the syllabus. The topics in this lecture are all in Chapter 12. 1 Interpolation Oftentimes when you gather data, youll want to estimate the values of intermediate points. To do this in Matlab, you use interpolation , those methods that draw lines or curves between measured (or observed) points so that you can estimate intermediate values. 1.1 Linear Interpolation The simplest method of interpolation is linear interpolation, which basically encompasses drawing a line between each consecutive data point that you measure. Then, to estimate any intermediate value, you just find that point on those lines. Note that linear interpolation doesnt draw one line that fits all of the data points. It draws many small lines that connect every consecutive point. Thus, each measured data point is the endpoint of a line. To perform linear interpolation in Matlab, you use the interp1 function. Note that the last charac ter in the functions name is the number one, not the letter L. The interp1 function requires 3 input arguments: a vector containing the x points you measured, a vector containing the y points you measured, and a third vector containing the new x values for which you want to estimate the values of y points. The function returns a vector of estimates for those y values. The example below shows 5 measured data points, stored as x and y. We then use interp1 to estimate y values for x values from 1 to 5, in intervals of 0.1. Below, you can see the resulting plot, in which the measured points are simply Os, whereas the lines connecting those points are actually the interpolated values. Note that the interpolated lines go through each of the measured data points. x=1:5; y = [2 6 6.2 7.4 10]; newx = 1:0.1:5; newy = interp1(x,y,newx); plot(x,y,O,newx,newy) 1.2 Cubic Spline Interpolation Instead of drawing lines between points, you sometimes instead want to draw curves that snake through each of those points. This method of using curves to smoothly connect points is known as cubic spline interpolation and is used extensively in computer graphics (i.e. keyframe animation), image processing, and motion control for robots....
View
Full
Document
This note was uploaded on 11/09/2011 for the course ENGINEERIN 127 taught by Professor Finch during the Fall '08 term at Rutgers.
 Fall '08
 Finch

Click to edit the document details