Geen 052

# Geen 052 - r LEW GEEN 023/052 MIDTERM TEST SPRING 2008 1...

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

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

View Full Document

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.

Unformatted text preview: \ ' r LEW / GEEN 023/052 MIDTERM TEST SPRING 2008 1. Describe what the following MATLAB commands do (be as speciﬁc as possible): 3‘ 3w: I: ‘51 £34“! V * funk? w, ‘ rem(3,2) #5:; a: r' «‘3 s :i- ‘ 3’"- w :1" ’” i .t ] zeros(1i3) i l ‘a. age = inputCHow iald ‘are you?) J» ‘2! :‘Z' “5 Mg“ .1' 1 (’15 at: r 5-H _: “of ‘c'vi M 1: , e: ‘: ~' it Li J . . u. 2-- :63. J , lilac (LE: ,1}: a: 5? g firm, K‘f‘thhil- Ks! t, :a e (typify - r f‘gr i Vital" an a M i ./, " i . r a “qu7 ,, ‘.:~.-'.‘;;U,~.#l v "wng '. ' if 2. Show the contents of the A array for the foiiowinci exoressions Ali's i A = [-4:4] A = [13:16] a"; g 2,7 W Aalinspace(0,2,5) (3; (53,125, E; 7a: :4. i L i -’ 3- Refer to the function deﬁnition ﬁne to answer questions 3-5: A = [7; 10; 21] function [dist, vel, accel] = motion (x) 3. What is the function name? in 5/ - Fifi 4. What is the function input? v _ 5. What is the function output? . ' l _V :yir" V"' [ :;,5-i':‘,?.b=47' (17‘15‘5‘ Lip 4 (9L ” fry; 1:! ‘ ' Refer to the Matrix U deﬁned below to answer questions 6~9: 1 6. What is the size of U? 8. What is the value of U(3,:)? a. ll {0 M = i~2 is ill c. 10. In the space below, write the Output of the following MATLAB statements: I 5 118 [-6 £20 I3 4| 3i 2i 9| 0| ~1 n u 7 2 0 1 44 b. 2i 7! 12] 9! -8i Ir M M:eye(5) fori = 1:3 end disp(i) M a"? Is [9 =10 l-ﬁ £21 *3. .t ‘}J 7. What IS the value of U(2,3)? 4 4 8 7 2 O 14 -9 \ t i 3:. 'l-‘il‘ll \ i 3 44 21 82 mwmoow (NO 1% 9i 1| 3i 9| ., m _ _ f Which of the following ivi matrices cannot be multiplied by 'U’? (M’FU) ism} In problems 11 — 15, indicate which method (a-e) should be invoked to solve the following types of problems: METHOD: a. Element—by—element operations b. Ef—else-end structure Loops . Functions Matrix division seen PROBLEM TYPE: 11. Repeating the same command or group of commands. ﬁr” 13. Using input data to carry out calculations and determine output. 3?} 12. Solving a system of linear equations. 14. Choosing one group of commands out of several groups of commands for execution. 15. Carrying out multiplication or division on each individual element of an array. s f”? —l— In Problems 16 — 18, give MATLAB statements that perform the steps indicated. Assume that the variables are scalars. 16. If the radius of a circle is larger than 10.0, calculate the area of the circle. Ca“ Loire... liar .. ‘ J 5'Lf’gxli‘" H ; draw-va :va l \f‘wh’ “a; an; area. ‘. i» - . F A: . 17. Choose a random number, r, between 3 and 30. .4 ‘ v“ J H a "I ‘l {L x K .21 x “4hwa 4r Yen-rid ‘ 18. Output a graph of y=sin(x) for the values of x between —2 and 2. ("Fiﬁ-AL 5‘ ‘ if; 5' \$3"? 5w 3' a : .05 I 19. What is the output of the following MATLAB statements? scores = [76, 45, 98, 97]; count = 0; k = 0; while I: < 4 k = k + 1; if scores (k) > 90 count = count + 1; end end disp (count) if 20. How can we repeat the following guessing game (using MATLAB commands) until the user decides to quit playing? Show appropriate lines of code. number = round(rand*99 + 1) dispCGuess a number between 1 and 100. You have three tries.’) for i = 1:3 guess = inputCWhat is your guess ?’) if guess < number dispCToo Low’) elseif guess > number dispCToo High? else dispCYou are Correct!!’) break end end fprinthThe number is %g.’,number) _ V, E 51 l! I‘k ...
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

Geen 052 - r LEW GEEN 023/052 MIDTERM TEST SPRING 2008 1...

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

View Full Document
Ask a homework question - tutors are online