ENGINEERING COURSES FOR UNDERGRADUATE STUDENTS

LECTURES & APPLICATIONS
 
HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Polynomials and Fitting

Go down 
AuthorMessage
Eng.Saeed Almalowi



Posts : 38
Join date : 2009-10-27
Location : UNITED STATE OF AMERICA, STATE COLLEGE,PA

PostSubject: Polynomials and Fitting   Thu Oct 29, 2009 6:51 am

Matlab can treat a vector as a polynomial. It will assume that the numbers represent the coefficients of the polynomial going from highest-order to lowest order.

>>p = [1 2 2 4 1]

can represent the polynomial x^4 + 2x^3 + 2x^2 + 4x + 1. There are a number of functions that use this representation of polynomials:

>>roots(p)

gives you the roots of the polynomail represented by the vector p.

>>polyval(p,4)

gives you the value of the polynomial p when x = 4. Similarly,

>>polyval(p,[1:10])

gives you the value of the polynomial evaluated at each of the points in the vector. (It returns another vector the same size.)

You can fit polynomials to data sets using this representation and a function called curvefit.

>>[p, fitted] = curvefit(x,y,n)

fits the data in x and y to an nth order polynomial (using 1 gives you a straight line, 2 gives you a quadratic, etc), and plots both the data and the fitted curve for you. It returns p, the polynomial representing the equation of the fitted curve, and fitted, the data points you get from the curvefit for each of the x's in your data set.

You can use polyval and the fitted polynomial p to predict the y value of the data you've fitted for some other x values.

>>ypred = polyval(p,xvalues)
Back to top Go down
View user profile http://www.aalhameed1.net
 
Polynomials and Fitting
Back to top 
Page 1 of 1
 Similar topics
-
» Senate Bill No. 2881
» PNP tailor-fit specs for Mike Arroyo choppers
» cause of rod thermostat failure
» Boilermate and Water Softener
» slow leak from temperature sensor

Permissions in this forum:You cannot reply to topics in this forum
ENGINEERING COURSES FOR UNDERGRADUATE STUDENTS :: ENGINEERING PROGRAMS/SOFT WARE :: MATLAB PROGRAM FORUM-
Jump to: