Pre-Engineering 220 Introduction to MatLab ® & Scientific Programming j kiefer



Download 8.69 Mb.
Page70/128
Date02.05.2018
Size8.69 Mb.
#47255
1   ...   66   67   68   69   70   71   72   73   ...   128

The sixth degree polynomial constructed from this table is

.

Line by line, the script might look like this:

fac = ex – x(1)

p0 = diff(1,1)

p1 = p0 + fac*diff(1,2)

fac = fac*(ex-x(2))

p2 = p1 + fac*diff(1,3)

fac = fac*(ex-x(3))

p3 = p2 + fac*diff(1,4)

fac = fac*(ex-x(4))

p4 = p3 + fac*diff(1,5))

fac = fac*(ex-x(5))

p5 = p4 + fac*diff(1,6)

fac = fac*(ex-x(6))

p6 = p5 + fac*diff(1,7)

Notice that we must use a different variable name for the argument x from the name used for the data array x(i).


Of course, it’s more general and flexible to use a loop.
fac = 1.0

p = diff(1,1)

for j=1:n

fac = fac*(ex-x(j))

p = p + fac*diff(1,j+1)

end
e. Issues with high degree polynomials



If we have a large number of data points, 20 or 100 or 1000s, it does not pay to use the entire data table to create a 20 or 100 or 1000th degree polynomial. The greater the degree, the more often the pn goes up and down between the data points. Our confidence that actually decreases. It’s better to interpolate on subsets of the data using a p3 or a p4 using data points that surround the specified x. This process can be incorporated into the program. These low-degree segments are sometimes called splines.


Download 8.69 Mb.

Share with your friends:
1   ...   66   67   68   69   70   71   72   73   ...   128




The database is protected by copyright ©ininet.org 2024
send message

    Main page