{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# lab9 - Chapter 8 Curve Fitting and Calculus with Matlab A...

This preview shows pages 1–4. Sign up to view the full content.

Chapter 8 Curve Fitting and Calculus with Matlab DATA CUBIC FIT 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 car’s performance including its acceleration, handling characteristics, and crash-test 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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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. 8.1.3 Least Squares Straight Line Fitting In the previous section we simply guessed the form of a straight line fit. But, what is the best fitting staight line to the data in the table? The best fit line is the one that minimizes the total squared error e . Here, we will use MATLAB’s built in functions to find the best fit. Type HELP POLYFIT and you will see something like this: POLYFIT Fit polynomial to data.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 12

lab9 - Chapter 8 Curve Fitting and Calculus with Matlab A...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online