MATLAB: Quiz 1
Evaluate the following expression: 3 == 5 + 2
0
Evaluate the following expression: XOR ( 5 < 6, 8 > 4)
0
Assuming that there is a variable x of type double that has already been initialized (so it already has a value), evaluate the following expression: 2 < x < 7
1
fix(-4.2) evaluates to the same value as floor(-4.2). Select one: True False
False
Converting a value from one type to another is known as Select one: a. casting b. concatenation c. metamorphosis d. ghostin e. truncation
a. casting
What MATLAB function(s) would round 1.4 to 2.0? Select one: a. ceil(1.4) b. round(1.4) and ceil(1.4) c. floor(1.4) d. fix(1.4) e. round(1.4) and floor(1.4) f. round(1.4)
a. ceil(1.4)
The MATLAB function mod(X,Y) Select one: a. finds the remainder (modulus) of X divided by Y b. finds the least common multiple of X and Y c. finds the greatest common factor between X and Y d. calculates the mode of values X and Y
a. finds the remainder (modulus of X divided by Y
Which of the following is not a datatype in MATLAB? Select one: a. hexadecimal b. char c. int32 d. double e. logical
a. hexadecimal
Which of the following is a valid variable name? Select one: a. score_1 b. score 1 c. 1_score d. 1score
a. score_1
What does a semicolon at the end of a line of MATLAB code do? Select one: a. It prints the output of that line to the command window b. It keeps the output of that line from being printed to the command window c. If you don't put a semicolon at the end of every line the code won't run d. It comments out the line so that it won't be run
b. It keeps the output of that line from being printed to the command window
Which of the following commands will generate a random real number bigger than 20 and smaller than 40 Select one: a. randi([20,40]) b. rand()*20 + 20 c. rand([0,1])*20 + 20 d. rand(20,40)
b. rand()*20+20
What is value of ans after the following code is executed? >> 5 * 5; >> ans + 3; Select one: a. Error, undefined function or variable 'ans' b. 25 c. 3 d. 28 e. 253
d. 28
What is the value of myNum after the following code is executed? >>myNum = 6; >>myNum + 5; >>myNum = myNum - 3; Select one: a. 11 b. 8 c. Error, variables cannot be changed after assignment d. 3 e. 6
d. 3
What is the value of ans after the following code is executed? >>myNum = 6; >>myNum = myNum + 3; >>myNum - 5; Select one: a. 8 b. 3 c. 6 d. 4 e. Error, variables cannot be changed after assignment
d. 4
Which of the following is a valid variable name? Select one: a. !ninety_nine_problems b. 99_problems c. 99problems d. None of the above
d. None of the above
What is the difference between the following two code fragments? res = 9 - 2; and res = 9 - 2 Select one: a. When the semicolon is included, the new value of the variable 'res' will be displayed in the Command Window b. The first results won't c. The second results in an error d. When the semicolon is omitted, the new value of the variable 'res' will be displayed in the Command Window
d. When the semicolon is omitted, the new value of the variable 'res' will be displayed in the Command Window
By default, numbers in MATLAB are stored as type Select one: a. binary b. uint64 c. float d. double e. single
d. double
What is the value of ans after the following code is executed? >>1; >>ans + 5; >>6 - ans; Select one: a. 1 b. Error, undefined function or variable 'ans' c. 3d. 6 e. 0
e. 0
What is value of myNum after the following code is executed? >> myNum = 3; >> myNum = 4 + 2; >> myNum = myNum + 1; Select one: a. 1 b. 11 c. 3 d. Error, variables cannot be changed after assignment e. 7
e. 7
What must a variable name begin with? Select one: a. A number b. Any UNICODE character c. >> d. A space e. A letter
e. A letter