MatLab – Palm Chapter 5 Curve Fitting

Slides:



Advertisements
Similar presentations
WARM UP 1. Explain how to graph a linear equation written in slope-intercept form. 2. Explain how to graph a linear equation written in point-slope form.
Advertisements

Bellringer.
Empirical Model Building I: Objectives: By the end of this class you should be able to: find the equation of the “best fit” line for a linear model explain.
Class 7.2: Graphical Analysis and Excel Solving Problems Using Graphical Analysis.
Correlation and regression
EGR 105 Foundations of Engineering I
Excel Part III Curve-Fitting, Regression Section 8 Fall 2013 EGR 105 Foundations of Engineering I.
CITS2401 Computer Analysis & Visualisation
Engineering Fundamentals and Problem Solving, 6e Chapter 5 Representation of Technical Information.
EGR 105 Foundations of Engineering I Fall 2007 – week 7 Excel part 3 - regression.
EGR 105 Foundations of Engineering I Fall 2007 – week 7 Excel part 3 - regression.
Chapter 5 Plotting Data Curve Fitting, Good Graphing Practices Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Lesson Nonlinear Regression: Transformations.
Least-Squares Regression
CMPS1371 Introduction to Computing for Engineers NUMERICAL METHODS.
Graphing Linear Equations
Empirical Model Building Ib: Objectives: By the end of this class you should be able to: Determine the coefficients for any of the basic two parameter.
Introduction to MATLAB for Engineers, Third Edition Chapter 6 Model Building and Regression PowerPoint to accompany Copyright © The McGraw-Hill Companies,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Chapter 13 The Math for Graphing in DC Circuits. Graphing Overview  Critical for practical analysis many different natural systems. Note: Theoretical.
Ch 7 Graphs and Linear Equations Review on Graphing.
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers Chapter 5B Model.
11/20/2015ENGR 111A - Fall MatLab – Palm Chapter 5 Curve Fitting Class 14.1 Palm Chapter:
College Algebra Acosta/Karwoski. CHAPTER 1 linear equations/functions.
Solving Exponential Equations. We can solve exponential equations using logarithms. By converting to a logarithm, we can move the variable from the exponent.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
Understand the system of simultaneous linear equations. Solve the system of simultaneous linear equations involving two variables. Students and Teachers.
The General Linear Model. Estimation -- The General Linear Model Formula for a straight line y = b 0 + b 1 x x y.
Ch 7 Graphs and Linear Equations Review on Graphing.
Tables & Graphing Laboratory Skills. Basic Tables Tables, or charts, are used to organize information Tables, or charts, are used to organize information.
3-3A Linear Functions Algebra 1 Glencoe McGraw-HillLinda Stamper.
Fitting Equations to Data Chapter 7. Problems Classwork: 7.1, 7.8, 7.13, 7.22 Homework: 7.2, 7.9, 7.16, 7.23, 7.28.
Lecture 29: Modeling Data. Data Modeling Interpolate between data points, using either linear or cubic spline models Model a set of data points as a polynomial.
Chapter 2 Functions and Graphs
Chapter 4 Systems of Linear Equations; Matrices
7.7A Write Exponential Functions
Fitting Equations to Data
Linear Equations in Two Variables
Today we will graph linear equations in slope intercept form.
Graphing Linear Equations
Chapter 1 Linear Equations and Graphs
Writing Linear Equations in Slope-Intercept Form
Quick Graphs of Linear Equations
HW: Get Ready for Chapter 4 (back of agenda)
WARM UP In the composite function m(d(x)), function d is called the ____________ function. Give another symbol for m(d(x)). If f(x) = 2x and g(x) = x.
Chapter 4 Systems of Linear Equations; Matrices
Lial/Hungerford/Holcomb/Mullins: Mathematics with Applications 11e Finite Mathematics with Applications 11e Copyright ©2015 Pearson Education, Inc. All.
Graphing Linear Functions
4.2 Polynomial Functions and Models
Introduction to MATLAB 7
Lecture 10 2D plotting & curve fitting
Graphing Linear Equations
Fitting Curves to Data Lesson 4.4B.
Linear Equations in Two Variables
Lesson 3: Linear Relations
Introduction to Engineering Linear & Logarithmic Scales
Regression.
Graphing Linear Equations
Moving Straight Ahead Students will work on linear equations, solving equations, solving inequalities, determining slopes and what they mean, and determining.
Graphing Linear Equations
A. Draw a trend line. It will be easier to write an equation
3 Chapter Chapter 2 Graphing.
Objective graph linear equations using slope-intercept form.
7.2 Graphing Equations Objectives:
7.2 Graphing Equations.
Chapters Important Concepts and Terms
5-3 slope-intercept form
Algebra: Graphs, Functions, and Linear Systems
Presentation transcript:

MatLab – Palm Chapter 5 Curve Fitting Class 14.1 Palm Chapter: 5.5-5.7 12/1/2018 ENGR 111A - Fall 2004

RAT 14.1 As in INDIVIDUAL you have 1 minute to answer the following question and another 30 seconds to turn it in. Ready? When (day and time) and where is Exam #3? The answer is: Thursday at 6:30 pm, Bright 124 Do we have any schedule problems? 12/1/2018 ENGR 111A - Fall 2004

Learning Objectives Students should be able to: Use the Function Discovery (i.e., curve fitting) Techniques Use Regression Analysis 12/1/2018 ENGR 111A - Fall 2004

5.5 Function Discovery Engineers use a few standard functions to represent physical conditions for design purposes. They are: Linear: y(x) = mx + b Power: y(x) = bxm Exponential: y(x) = bemx (Naperian) y(x) = b(10)mx (Briggsian) The corresponding plot types are explained at the top of p. 299. 12/1/2018 ENGR 111A - Fall 2004

Steps for Function Discovery Examine data and theory near the origin; look for zeros and ones for a hint as to type. Plot using rectilinear scales; if it is a straight line, it’s linear. Otherwise: y(0) = 0 try power function Otherwise, try exponential function If power function, log-log is a straight line. If exponential, semi-log is a straight line. 12/1/2018 ENGR 111A - Fall 2004

Example Function Calls polyfit( ) will provide the slope and y-intercept of the BEST fit line if a line function is specified. Linear: polyfit(x, y, 1) Power: polyfit(log10(x),log10(y),1) Exponential: polyfit(x,log10(y),1); Briggsian polyfit(x,log(y),1); Naperian Note: the use of log10( ) or log( ) to transform the data to a linear dataset. 12/1/2018 ENGR 111A - Fall 2004

Example 5.5-1: Cantilever Beam Deflection First, input the data table on page 304. Next, plot deflection versus force (use data symbols or a line?) Then, add axes and labels. Use polyfit() to fit a line. Hold the plot and add the fitted line to your graph. 12/1/2018 ENGR 111A - Fall 2004

Solution 12/1/2018 ENGR 111A - Fall 2004

Straight Line Plots Forms of Equation Straight Line Systems MatLab Syntax Linear Equation y = mx + b Rectilinear System plot(x,y) Power Equation y=bxm Loglog System loglog(x,y) Exponential Equation y = bemx or y=b10mx Semilog System semilogy(x,y) 12/1/2018 ENGR 111A - Fall 2004

Why do these plot as lines? Exponential function: y = bemx Take the Naperian logarithm of both sides: ln(y) = ln(bemx) ln(y) = ln(b) + mx(ln(e)) ln(y) = ln(b) + mx Thus, if the x value is plotted on a linear scale and the y value on a log scale, it is a straight line with a slope of m and y-intercept of ln(b). 12/1/2018 ENGR 111A - Fall 2004

Why do these plot as lines? Exponential function: y = b10mx Take the Briggsian logarithm of both sides: log(y) = log(b10mx) log(y) = log(b) + mx(log(10)) log(y) = log(b) + mx Thus, if the x value is plotted on a linear scale and the y value on a log scale, it is a straight line. (Same as Naperian.) 12/1/2018 ENGR 111A - Fall 2004

Why do these plot as lines? Power function: y = bxm Take the Briggsian logarithm of both sides: log(y) = log(bxm) log(y) = log(b) + log(xm) log(y) = log(b) + mlog(x) Thus, if the x and y values are plotted on a on a log scale, it is a straight line. (Same can be done with Naperian log.) 12/1/2018 ENGR 111A - Fall 2004

In-class Assignment 14.1.1 Given: x=[1 2 3 4 5 6 7 8 9 10]; y1=[3 5 7 8 10 14 15 17 20 21]; y2=[3 8 16 24 34 44 56 68 81 95]; y3=[8 11 15 20 27 36 49 66 89 121]; Use MATLAB to plot x vs each of the y data sets. Chose the best coordinate system for the data. Be ready to explain why the system you chose is the best one. 12/1/2018 ENGR 111A - Fall 2004

Solution 12/1/2018 ENGR 111A - Fall 2004

Be Careful What value does the first tick mark after 100 represent? What about the tick mark after 101 or 102? Where is zero on a log scale? Or -25? See pages 282 and 284 of Palm for more special characteristics of logarithmic plots. 12/1/2018 ENGR 111A - Fall 2004

How to use polyfit command. Linear: pl = polyfit(x, y, 1) m = pl(1); b = pl(2) of BEST FIT line. Power: pp = polyfit(log10(x),log10(y),1) m = pp(1); b = 10^pp(2) of BEST FIT line. Exponential: pe = polyfit(x,log10(y),1) m = pe(1); b = 10^pe(2), best fit line using Briggsian base. OR pe = polyfit(x,log(y),1) m = pe(1); b = exp(pe(2)), best fit line using Naperian base. 12/1/2018 ENGR 111A - Fall 2004

In-class Assignment 14.1.2 Determine the equation of the best-fit line for each of the data sets in In-class Assignment 14.1.1 Hint: use the result from ICA 14.1.1 and the polyfit( ) function in MatLab. Plot the fitted lines in the figure. 12/1/2018 ENGR 111A - Fall 2004

Solution 12/1/2018 ENGR 111A - Fall 2004

5.6 Regression Analysis Involves a dependent variable (y) as a function of an independent variable (x), generally: y = mx + b We use a “best fit” line through the data as an approximation to establish the values of: m = slope and b = y-axis intercept. We either “eye ball” a line with a straight-edge or use the method of least squares to find these values. 12/1/2018 ENGR 111A - Fall 2004

Curve Fits by Least Squares Use Linear Regression unless you know that the data follows a different pattern: like n-degree polynomials, multiple linear, log-log, etc. We will explore 1st (linear), … 4th order fits. Cubic splines (piecewise, cubic) are a recently developed mathematical technique that closely follows the “ship’s” curves and analogue spline curves used in design offices for centuries for airplane and ship building. Curve fitting is a common practice used my engineers. 12/1/2018 ENGR 111A - Fall 2004

T5.6-1 Solve problem T5.6-1 on page 318. Notice that the fit looks better the higher the order – you can make it go through the points. Use your fitted curves to estimate y at x = 10. Which order polynomial do you trust more out at x = 10? Why? 12/1/2018 ENGR 111A - Fall 2004

Solution 12/1/2018 ENGR 111A - Fall 2004

Solution 12/1/2018 ENGR 111A - Fall 2004

Assignment 14.1 Prepare for Exam #3. Group Projects are due at Exam #3 (parts 1 through 3 required; parts 4 and 5 as extra credit) 12/1/2018 ENGR 111A - Fall 2004