Midterm 2 Practice Problems - Page 2 Part A (10 points)...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 2 Name: PartA ( 10points ) A.1 ( 3points )CompletethefollowingMATLABfunction,called currency conv . function Aout=currency_conv(Ain,Tin,Tout) % The function converts money from one currency to % another. % Ain : input amount % Tin : input currency type % Tout: currency type for output % Aout: output amount (to be determined) % Types of currency are denoted by a letter as follows: % D for Dollars % E for Euros % The exchange rate is: 1 dollar (D) = 0.75 Euros (E) if Tin==Tout Aout = Ain; else switch Tin % Dollars to Euros case ____________________ % add code here _______________________ % add code here % Euros to Dollars case ____________________ % add code here _______________________ % add code here end end E77 Midterm 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page 3 Name: A.2 ( 3points ) Given the function y ( x )= 3 x 5 +3 x 3 , complete the following MATLAB script to plot y (vertical axis) as a function of x (horizontal axis),for x rangingbetween 1 to 1, with an increment of 0.1. Plot a bluestarat pointswhere the derivativeof y ( x ) is greaterthan orequal to zero, and plot a red star at points where the derivativeof y ( x ) is less than zero. x = -1:0.1:1; y=- 3 * x.ˆ5 + 3 * x.ˆ3; plot(x,y) hold on % yp is the derivative of y yp = _______________________________ % add code here for k= _____________________________ % add code here if _______________________________ % add code here plot(x(k),y(k),’b * ’) else plot(x(k),y(k),’r * ’) end end
Background image of page 2
Page 4 Name: A.3 ( 4points )Let >> A = [1 2 3 4]; >> B = [1 0]; >> X = 1:4; Record the output of each of the following MATLAB commands: >> C = conv(A,B) C= >> D = polyval(B,X) D= >>E=A+2 * [B B] E= E77 Midterm 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Page 5 Name: PartB ( 8points ) The arrays A and B are generated by the MATLAB code below: A = zeros(3,3); B = zeros(3,1); for k= [3 1 2] for m=0:2 A(k,m+1) = A(k,m+1) + k + m; for n=1:2 B(k) = B(k) + n; end end end A B B.1 ( 4points ) What are the values of A and B after execution of the above code? A= B= E77 Midterm 2
Background image of page 4
Page 6 Name: B.2 ( 4points ) Consider the following system of linear algebraic equations: x 1 +2 x 2 + x 3 =5 x 1 =1 x 1 +3 x 3 =1 3 The system can be put in the form [ A ][ x ]=[ b ] ,where [ A ] is a 3 × 3 array, [ b ] is a 3 × 1 array and [ x ]= x 1 x 2 x 3 .
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

Midterm 2 Practice Problems - Page 2 Part A (10 points)...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online