This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Chapter 8 Curve Fitting and Calculus with Matlab D A T A C U B IC F IT 8.1 Curve Fitting Often the goal of engineering is to ultimately build something, like maybe a car, for example. Engineers will carefully design the car using theoretical models and computer simulations that predict the cars performance including its acceleration, handling characteristics, and crashtest performance. Ultimately, the car is built and the engineering predictions can be compared with actual measurements made on the final product. Curve fitting provides a means of comparing real world measurements with the predictions of engineering models. 83 CHAPTER 8. CURVE FITTING AND CALCULUS WITH MATLAB 84 8.1.1 An Example Data Set In this lab exersice, we will consider some measurements of sound amplitude inside a ventilation duct. The following table lists measured values of sound amplitude at various distances along the duct: Amplitude, y Distance, x 7.5 .15 5.6 1.04 4.4 1.44 3.6 1.84 3.0 2.24 2.5 2.64 2.2 3.04 1.9 3.44 1.5 3.84 1.1 4.24 As the sound propagates through the duct, it gradually looses amplitude. We will be analyzing this data in a variety of ways. The goal of our analysis is to find a curve (as generated by an equation) that seems to describe our data. By fitting an equation to our data, we can (among other things) use the equation to predict the sound amplitude at points along the duct where no measurement exists. 8.1.2 Fitting a Straight Line to Data Points The crudest method of curve fitting is to make a simple guess. Looking at the table of data, notice that the amplitude decreases with increasing distance (it has a negative slope). Also, notice that it starts out at with amplitude of 7.5 at distance 0.15. We start by guessing that the data fits a straight line given by f ( x ) = 2 x + 8 (8.1) Problem 8.1 On the same set of axes, plot the data in the table above and the straight line given by Eq. (8.1). The data should be plotted WITHOUT drawing a line between the points. Equation (8.1) should be plotted as a solid line. Turn in your figure and the MATLAB code that generate the figure. The total squared error in our curve fit is defined as e = N X i =1 [ f ( x i ) y ( i )] 2 CHAPTER 8. CURVE FITTING AND CALCULUS WITH MATLAB 85 where N is the number of data points (we have 10 in this case). The quantity e is always a positive number and is zero when the curve fits the data exactly. Problem 8.2 In MATLAB, calculate e for the data set and the curve fit given by Eq. (8.1). (You do not have to use a FOR loop. It is much easier to perform vector subtraction, square the result, and then use the SUM command.) Turn in the value obtained for e and the lines of code used in the calculation....
View
Full
Document
This note was uploaded on 12/14/2011 for the course ME 218 taught by Professor Unknown during the Fall '08 term at University of Texas at Austin.
 Fall '08
 Unknown

Click to edit the document details