Sie sind auf Seite 1von 3

0.0.

Math 20300 EE Matlab Final Examination IA (Spring 2007) Instructions: Answer all questions in Part I in the space provided. No calculators are permitted. Matlab is the only computational tool permitted on the exam. All answers are to printed legibly and completely on these sheets. Correct punctuation is important. In other words, you must include or not include commas, brackets, colons, semi-colons, etc. where appropriate. No computer printouts will be accepted. Unless otherwise noted, you can assume that all output is meant to be displayed.

Part I: Answer all 10 questions in this part. No partial credit for incorrect answers. Please print legibly. Total of 60 points. 1. (5 points) State a single Matlab command that will assign to the variable x the vector [5, 10, 15, . . . , 990, 995, 1000] without displaying the result. Answer: >> x = 5 : 5 : 1000; or >> x = linspace(5, 1000, 200); or >> x = 5 : (10005)/199 : 1000; 2. (5 points) What Matlab command will write the text My graph as the title of a graph? Answer: >> title(My graph) 3. (5 points) If x = [1 2 3 4], what Matlab expression involving x will produce the output [1 22 33 44 ], i.e., [1 4 27 256]? Answer: >> x. x 4. (5 points) Which of the following symbols is used to begin a comment in an M-le? (Circle the correct choice.) Answer: %. 5. (5 points) How would you create a vector containing 20 equally spaced numbers in the interval [0, 2]? Answer: >> x = linspace (0, 2 , 20); or >> x = [0 : 2 /19 : 2 ];
x+y x2 + y 2

6. (7 points) State the command constructs f (x, y) = function of two variables. Answer: >> f = @(x, y)(x + y)./(x. 2 + y. 2) 7. (7 points) What is the exact value of not be considered exact.) Answer: >> 15/2 log(3) 2/3
4 0 x log(1

as an anonymous vectorized

x) dx? (In this case a decimal answer will

8. (7 points) Find Matlabs numerical estimate for the value of


1

ex dx. 1 + x2 1.468972

Answer: (ll in all spaces, except leading zeros):

The code: >> quad (exp(x)./ sqrt(1 + x. 2) , 0, 1, 0.0000001)

0.

9. (7 points) If z =

sin(xy) cos(x2 + y 2 )

, nd the numerical value of

2z x2

at x = 1, y = 2.

Answer: (ll in all spaces, except leading zeros): The code: >> >> >> >> >>

311.0647

syms x y z = sin(x y) / cos(x 2 + y 2); zxx = di(z, x, 2); Zxx = fcnchk(char(zxx), x, y, vectorized); Zxx(1, 2)

10. (7 points) In the series of commands below, a student is trying to generate a plot of z = x2 + y 2 over the rectangle where 0 x 4, and 0 y 3, without using symbolic variables. In the blank lines provided below, insert the appropriate command(s) needed to complete the task. Answer: >> >> >> >> >> x = linspace (0, 4, 25); % This was given y = linspace(0, 3, 25); % This was given [X, Y ] = meshgrid (x, y); Z = X. 2 + Y. 2; surf(X, Y, Z)

Part II: Answer problem 11 and EITHER 12 or 13. Partial credit for incorrect answers may be given at the discretion of the instructor. Each question is worth 20 points. 11. Suppose f (x, y) = sin(3x + y) 2 cos(x y). a) In the spaces below, state a sequence of Matlab commands that will produce 15 labeled contour curves for f (x, y) over the square S = {(x, y) | 0 x 2, 0 y 2}. >> >> >> >> >> >> x = 0 : 0.01 : 2; y = 0 : 0.01 : 2; [X, Y ] = meshgrid(x, y); Z = sin(3. X + Y ) 2. cos(X Y ). ones(size(X)); [C, h] = contour(X, Y, Z, 15); clabel(C, h)

Answer:

0.0. b)

Based on the contour plot you found in a) determine whether the function has any critical points in the square S dened in 11a). If there are any such pints, provide estimates from the graph for their x and y coordinates and provide a justication from the graph as to whether these are relative maxima, minima or saddle points.

Answer: Base on the contour plot (not shown here) we can see that f does have critical points in the square S and we estimate these to be (1.1781, 1.1781) and (0.3927, 0.3927) where f (1.1781, 1.1781) 3 is a relative minimum since the contour labels increase (decrease) as we move away (toward) from (1.1781, 1.1781) and f (0.3927, 0.3927) 1 is a saddle point since the contour labels increase and decreases in dierent direction as we approach the point.
sin x 12. a) Let y = x + x2 . You wish to have Matlab compute the formula for y and assign this 1 expression to a variable called dy. Give the exact code that will do this, including any commands needed to declare symbolic variables. (It is not necessary to show the actual value of the derivative in your answer.)

Answer:

>> syms x >> y = (x sin(x))/(1 + x 2); >> dy = di(y);

b) What Matlab command(s) will evaluate the derivative that you found in 12a) at each of the x values 1, 2, 3, 4, . . . , 99, 100? Answer: >> x = 1 : 100; >> dy = fcnchk(char(dy), x, vectorized); >> Dy = subs(dy(x), x, x);

Das könnte Ihnen auch gefallen