Engr 0012 (04-1) LecNotes 10-01 working toward a script that will help analyze data “Big” steps in accomplishing goal 1. Load data from file (have already.

Slides:



Advertisements
Similar presentations
1 Chapter 13 Curve Fitting and Correlation This chapter will be concerned primarily with two separate but closely interrelated processes: (1) the fitting.
Advertisements

EGR 105 Foundations of Engineering I
Excel Part III Curve-Fitting, Regression Section 8 Fall 2013 EGR 105 Foundations of Engineering I.
Notes Over 6.9Writing a Cubic Function Write the cubic function whose graph is shown.
Chemical Reaction Engineering Asynchronous Video Series Chapter 5: Finding the Rate Law H. Scott Fogler, Ph.D.
5  ECONOMETRICS CHAPTER Yi = B1 + B2 ln(Xi2) + ui
EGR 105 Foundations of Engineering I Fall 2007 – week 7 Excel part 3 - regression.
Part 4 Chapter 13 Linear Regression
EGR 105 Foundations of Engineering I Fall 2007 – week 7 Excel part 3 - regression.
Exam #3 Review: Comprehensive Exam Class 14.2 Palm Matlab Book Ch. 1-5.
6.5 & 6.6 Theorems About Roots and the Fundamental Theorem of Algebra
MONOMIALS NUMERIC VALUES OPERATIONS POLYNOMIALS NUMERIC VALUES (GRAPHING) OPERATIONS IDENTITIES.
10.1 – Exponents Notation that represents repeated multiplication of the same factor. where a is the base (or factor) and n is the exponent. Examples:
4.4 Adding and Subtracting Polynomials; Graphing Simple Polynomials
8.7 Modeling with Exponential & Power Functions p. 509.
7.6 Modeling Data: Exponential, Logarithmic, and Quadratic Functions.
Physics 114: Lecture 17 Least Squares Fit to Polynomial
9 - 1 Intrinsically Linear Regression Chapter Introduction In Chapter 7 we discussed some deviations from the assumptions of the regression model.
Products and Factors of Polynomials
1 Calculating Polynomials We will use a generic polynomial form of: where the coefficient values are known constants The value of x will be the input and.
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.
4.6 Solve Exponential and Logarithmic Equations
Chapter 9 Function Approximation
Introduction to MATLAB for Engineers, Third Edition Chapter 6 Model Building and Regression PowerPoint to accompany Copyright © The McGraw-Hill Companies,
Hydroinformatics: Session4 Dr Ivan Stoianov Room 328B Dr Andrew Ireson (Room 304) Mr Juan Rodriguez-Sanchez (411A) Mr Baback.
Fitting Exponentials and Polynomials to Data Lesson 11.7.
Chapter 5 Section 4 Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
7.1 An Introduction to Polynomials Objectives: Identify, evaluate, add, and subtract polynomials. Classify polynomials, and describe the shapes of their.
6.3 – Evaluating Polynomials. degree (of a monomial) 5x 2 y 3 degree =
Consider the following: Now, use the reciprocal function and tangent line to get an approximation. Lecture 31 – Approximating Functions
Introduction to Polynomials
Solve a logarithmic equation
Polynomials and Polynomial Functions
Intro to Logarithms Goes along with 4.4 (GREEN book) Quiz: 1/12/10 Logs Test: 1/21/10.
11/20/2015ENGR 111A - Fall MatLab – Palm Chapter 5 Curve Fitting Class 14.1 Palm Chapter:
4.3 Polynomials. Monomial: 1 term (ax n with n is a non- negative integers) Ex: 3x, -3, or 4y 2 Binomial: 2 terms Ex: 3x - 5, or 4y 2 + 3y Trinomial:
Copyright © 2009 Pearson Education, Inc. CHAPTER 4: Polynomial and Rational Functions 4.1 Polynomial Functions and Models 4.2 Graphing Polynomial Functions.
Section 4.4 Theorems about Zeros of Polynomial Functions Copyright ©2013, 2009, 2006, 2001 Pearson Education, Inc.
Polynomial Functions Definitions Degrees Graphing.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
5.2 – Evaluate and Graph Polynomial Functions Recall that a monomial is a number, variable, or a product of numbers and variables. A polynomial is a monomial.
Bell Problem Simplify the expression Evaluate and Graph Polynomial Standards: 1.Analyze situations using algebraic symbols 2.Analyze changes in.
Chapter 4 Working with Polynomials Important Terms.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
State the Domain and Range. 3  /2  /2  22 –1 1 -- -2  -3  /2-  /2.
Example 13.3 Quarterly Sales at Intel Regression-Based Trend Models.
Engr 0012 (04-1) LecNotes loading data from files >> file_name = input( 'Enter data file name ==> ','s') Enter data file name ==> c:\temp\speed_mpg.dat.
1 Lecture 8 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Introduction Previously, you learned how to graph logarithmic equations with bases other than 10. It may be necessary to convert other bases to common.
7.1 Polynomial Functions Objectives: 1.Evaluate polynomial functions. 2.Identify general shapes of graphs of polynomial function.
Advanced Algebra Notes Section 5.2: Evaluate and Graph Polynomial Functions A __________________ is a number, a variable, or the product of numbers and.
Polynomial P(x) Linear Factors Solutions of P(x)=0 Zeros of P(x) P(x) = 0.
Solving Exponential and Logarithmic Equations Section 3.4.
P.3 Functions & Their Graphs 1.Use function notation to represent and evaluate a function. 2.Find the domain and range of a function. 3.Sketch the graph.
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.
Introduction to Programming for Mechanical Engineers
Fitting Exponentials and Polynomials to Data
Salinity Calibration fit with MATLAB
Anatomy of Polynomials
Algebra II Section 5-3 Polynomial Functions.
Polynomial Functions and Models
Final Exam Review Part 2 - MATLAB
Chapter 9 Function Approximation
working toward a script that will help analyze data
Find all solutions of the polynomial equation by factoring and using the quadratic formula. x = 0 {image}
MatLab – Palm Chapter 5 Curve Fitting
2.3 Polynomial Functions of Higher Degree with Modeling
Discrete Least Squares Approximation
Polynomial Functions.
Polynomial Functions 1 Definitions 2 Degrees 3 Graphing.
Presentation transcript:

Engr 0012 (04-1) LecNotes working toward a script that will help analyze data “Big” steps in accomplishing goal 1. Load data from file (have already created function) 2. Display options 1. linear fit with equation and error 2. semi-log fit with equation and error 3. log-log fit with equation and error 4. linear display with polynomial-fit equation and error 5. linear display with spline-fit 3. Quantitative output to screen

Engr 0012 (04-1) LecNotes Polynomials Monomial A single term of the form a n x n where a n is a constant and n is either zero (0) or a positive integer examples 2.37x (3  /2)x 7 which of these are monomials? 2xsin(x) X sin(3  /2)x 4 (3-x)x 2 X

Engr 0012 (04-1) LecNotes Polynomials Polynomial A function that is the sum of a finite number of monomials. examples f(x) = x 3 - 5x +7  (z) = (3  /2)z 7 which of these are polynomials? d(t) = ½at 2 + v 0 t + d 0 y = 3x 3 - 2x 2 + xf(x) = 2x 2 - 3tan(x) g(z) = (1-z) 2 h(t) = 3  t 2 - 2t -1 X X

Engr 0012 (04-1) LecNotes Polynomials General Form y = f(x) = a n x n + a n-1 x n-1 + … + a 1 x + a 0 MATLAB P = [a n, a n-1, …, a 1, a 0 ] Coefficient vector If P is known, polynomial is completely defined y = f(x) = P(1)x n + P(2)x n-1 + … + P(n)x + P(n+1) (n+1) elements 1 + a 0 x 0 frequently omitted

Engr 0012 (04-1) LecNotes Polynomials MATLAB implementation >> P = 1:4 P = >> P(1) ans = 1 can access individual elements of vectors Evaluate y = f(x) at x = 2 using P vector just defined y = f(x) = P(1)x n + P(2)x n-1 + … + P(n)x + P(n+1) >> x=2; >> fatx = 0; >> for (i=1:1:4) fatx = fatx + P(i)*x^(4-i); end % for loop first introduction to a loop initialization type index counting limits/step size loop body this loop sums a series of numbers >> fatx fatx = 26 >> fatx2 = polyval(P,x) fatx2 = 26 MATLAB function that executes loop to evaluate a polynomial

Engr 0012 (04-1) LecNotes Data analysis >> load ca10a.dat >> xdata = ca10a(:,1); >> ydata = ca10a(:,2); >> plot(xdata,ydata,'r*') MATLAB - data “fitting” - looking for “best” fit polycoeff = polyfit(x,y,n) x  x data vector y  y data vector n  polynomial “degree” polycoeff  P (coefficient vector)

Engr 0012 (04-1) LecNotes Data analysis >> lincoef = polyfit(xdata,ydata,1) lincoef = ==> equation for linear data fit y = 0.67x >> xfit = linspace(xdata(1),xdata(length(xdata)),200) >> yfit = polyval(lincoef,xfit) length(x) tells how many elements are in vector x created a set of (x,y) points according to the “fit” >> hold on >> plot(xfit,yfit,'r-') >> hold off hold affects current graph hold on maintains current graph for additional plotting hold off erases current graph when additional plotting is done plotted a red line with (xfit,yfit) data points

Engr 0012 (04-1) LecNotes Data analysis created a linear plot with: original data points shown as asterisks linear fit shown as a line

Engr 0012 (04-1) LecNotes Data analysis >> clear >> load ca10b.dat >> xdata = ca10b(:,1)'; >> ydata = ca10b(:,2)'; >> plot(xdata,ydata,'r*')

Engr 0012 (04-1) LecNotes Data analysis >> semilogy(xdata,ydata,'r*') >> loglog(xdata,ydata,'r*')

Engr 0012 (04-1) LecNotes Data analysis looks like the data fit the equation y = Ax B how do we find A and B? transform equation (take ln of each side) ln(y) = ln(A) + Bln(x) can we use polyfit ? >> loglogcoef = polyfit( ) log(xpts), log = natural log in MATLAB log10 = base 10 log log(ypts),1 loglogcoef = B ln(A) >> B = loglogcoef(1); >> A = exp(loglogcoef(2)); >> xfit = linspace(xdata(1),xdata(length(xdata)),200); >> yfit = A*xfit^B;

Engr 0012 (04-1) LecNotes Data analysis >> hold on >> loglog(xfit,yfit,'r-') >> hold off created a log-log plot with: original data points shown as asterisks log-log fit shown as a line

Engr 0012 (04-1) LecNotes Data analysis Looks good - but we took log of data to create What if any of the data are negative? Exponential fitTake logarithms Need to delete any negative y-data and associated x-data % filter data for semi-log fit newx = [ ]; newy = [ ]; for i = 1:1:length(xdata) if ( ydata(i) > 0 ) newx = [newx xdata(i)]; newy = [newy ydata(i)]; end Easier to identify data to keep!!!

Engr 0012 (04-1) LecNotes Data analysis to use the extracted data set: polyfit % add line fit to graphical display semilogy(xnew,ynew,'r*', xfit,yfit,'r-') % determine fit to data semilogcoef = polyfit(xnew,log(ynew),1); B = semilogcoef(1); A = exp(semilogcoef(2)); % create (xfit,yfit) for line plot xfit = linspace(xnew(1),xnew(length(xnew)),200); yfit = A*exp(B*xfit); % add line fit to graphical display semilogy(xnew,ynew,'r*') hold on semilogy(xfit,yfit,'r-') hold off OR

Engr 0012 (04-1) LecNotes general strategy for graphical display % filter data set (if necessary) % find linear regression coefficients % create (xfit,yfit) for line plot % plot data, plot fit % do error analysis