1 / 10

Numerical Operations

Introduction to Matlab:. Numerical Operations. Polynomial Manipulations. S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn. Polynomial Topics. Entering Polynomials Roots Multiplication Evaluation Curve Fitting. Entering Polynomials.

peers
Download Presentation

Numerical Operations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Matlab: Numerical Operations Polynomial Manipulations S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn

  2. Polynomial Topics • Entering Polynomials • Roots • Multiplication • Evaluation • Curve Fitting

  3. Entering Polynomials • In Matlab, a polynomial is represented by a row vector of it’s coefficients in descending order • For example, the polynomial • Is entered as: » p=[1 -12 0 25 116] • Zero term coefficientsMUSTbe included

  4. Roots • To find the roots of a polynomial use roots • Roots are always column vectors » p=[1 -12 0 25 116]; » r=roots(p) r = 11.7473 2.7028 -1.2251 + 1.4672i -1.2251 - 1.4672i

  5. Mutliplication • Use the conv (convolution) command to evaluate the product of two polynomials: » a=[1 2 3 4];b=[1 4 9 16]; » c=conv(a,b) c = 1 6 20 50 75 84 64

  6. Evaluation • polyval is used to evaluate the polynomial p(x) between -1 and 3 » x=linspace(-1,3); % 100 data points » p=[1 4 -7 -10]; % Coefficients » v=polyval(p,x); % Evaluate » plot(x,v); » title('x^3 +4x^2 -7x -10'); » xlabel('x');

  7. Evaluation Plot

  8. Curve Fitting • polyfit implements a least squares curve fitting algorithm » x=[0:0.1:1]; » y=[-0.447 1.978 3.28 6.16 7.08 7.34 7.66 9.56 9.48 9.30 11.2]; » n=2; % Order of Fit » p=polyfit(x,y,n)

  9. Polyfit • Polyfit returns coefficients of curve fit solution » p = polyfit(x,y,n) p = -9.8108 20.1293 -0.0317

  10. Compare Solutions » xi=linspace(0,1,100); » z=polyval(p,xi); » plot(x,y,'-o',xi,z,':'); » xlabel('x'); » ylabel('y=f(x)'); » title('Second Order Curve Fitting'); • Least Mean Squared (LMS) Error Minimization

More Related