HW 7

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Engineering Analysis ME 349 Homework assignment 7 Due: Friday 7 March 2014 @ 2 pm in box outside my door Instructions: Be sure to include

de your name, section number, assignment number, and due date of the assignment at the top of the first page. Write the problem statement for each problem. If possible use an equation editor to create the problem statement, or you can write out the equation along with the number solution in pencil and attach the Matlab sessions (see next bullet) as an appendices. Once you have solved the problem on the Matlab Command Window, copy the relevant portion of the session to a Microsoft Word Document. If there is also work done on an m file (example a Script file), copy that also to the Word Document.

Problem 1 Write a UDF which evaluates a polynomial, y = ax 5 + bx 4 + cx 3 + dx 2 + ex + c1 . The constants, a, b, c, d , e, and c1 , should be declared in the command window and passed to the UDF using a global command. The value of x is passed into the UDF as an argument of the UDF function name. Create an output that states the polynomial being evaluated as well as the final value of the polynomial. Test your code on the polynomials, y= x 5 4 x3 + 3.1x 2 2 x + 10, where x = 3 y = 5 x5 4 x 4 + 3 x3 2 x 2 + x + 25, where x = 3 Problem 2 Create an anonymous function,

f= ( x ) e e x . Pass the function to the MATLAB


x

function, fzero, with an initial guess to determine the value of x that makes f(x) go to zero. Problem 3 Create a UDF for the function,

f= ( x ) e e x , define a handle for the UDF, and pass the


x

handle along with an initial guess to a second UDF that will use fzero to determine the value of x that makes f(x) go to zero. Problem 4 Do problem 3, except use the command feval to evaluate the second UDF.

Problem 5

Problem 6

Problem 7

You might also like