{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw6_solns

# hw6_solns - Mathematics of Engineering ME17 Spring 2007...

This preview shows pages 1–2. Sign up to view the full content.

Mathematics of Engineering - ME17 Spring 2007 Homework #6 - Solutions 1. (15 points total) (a) (2 pts) We need to plot the following data as circles ( x 1 , y 1 ) = (3 . 2 , 22 . 0) , ( x 2 , y 2 ) = (2 . 7 , 17 . 8) , ( x 3 , y 3 ) = (1 . 0 , 14 . 2) , ( x 4 , y 4 ) = (4 . 8 , 38 . 3) , ( x 5 , y 5 ) = (5 . 6 , 51 . 7) . see Matlab program below. (b) (4 pts) For this problem, we need to plot from x = 0 to x = 6 a cubic polyno- mial which goes through the first four data points on the same graph as for (a). This can be accomplished by using the polyfit and polyval functions in Matlab. The p1 = polyfit(x(1:4),y(1:4),3) command finds the coefficients of a polynomial p 1( x ) of degree 3 that fits the data y best in a least-squares sense. To plot the data, we use plot(xplot,polyval(p1,xplot),’k-’) , where the polyval returns the value of a poly- nomial p 1 evaluated at xplot . Note that we use x(1:4) and y(1:4) since we want to only consider the first four points. For the complete code, see the Matlab program below. (c) (4 pts) This part is exactly like part (b) but we now need to plot the cubic polynomial which best fits the five data points in the least-squares sense. The resulting plot from parts (a), (b), and (c) is given below. 0 1 2 3 4 5 6 10 15 20 25 30 35 40 45 50 55 60 Problem 1 x y data pts 4-pts fit least-squares fit Figure 1: Cubic polynomial fits.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

hw6_solns - Mathematics of Engineering ME17 Spring 2007...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online