
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

























What will the statement "myNum = 2 + 2" store in myNum? - Correct Answers ✅✅ 4 Suppose you want to automatically generate a vector of with 2 entries; the 1st entry starting at 0 and ends at 1. How would you create this vector in MATLAB? - Correct Answers ✅✅x = linspace(0,1,2) Whats another way to do this? - Correct Answers ✅✅0:1: Now Suppose you want to automatically generate a vector of 11 entries; the 1st entry starting at 0 and ends at 1. How would you create this vector in MATLAB? - Correct Answers ✅✅x = linspace(0,1,11) Whats another way to do this? - Correct Answers ✅✅0:1: Now Suppose you want to automatically generate a vector with 8 entries; the 1st entry starting at 0 and ends at 3. How would you create this vector in MATLAB? - Correct Answers ✅✅x = linspace(0,3,8) or x = 0:3: How would you access the first twelve elements for y? - Correct Answers ✅✅y = (1:12); x(1:12)
y = (1:12); x(1:12) How would you access the 1st four multiples of 3 specified in a vector?
ans = 1 5 9 2 6 10 3 7 11 4 8 12 If the previously-entered statement was "num1 = 5", what value will be stored in num2 after the statements "num1 = num1 + num1" followed by "num2 = num1 + 3". - Correct Answers ✅✅13;; The interpreter computes 5 + 5, which is 10, then stores 10 in num1. The interpreter then computes num1 + 3, which is 10 + 3 or 13, and stores 13 in num2. If the previously-entered statement was "num1 = 9", what value will be stored in num2 after the statement "num2 = num1 * num1"? - Correct Answers ✅✅ 81 If all previous statements dealt only with num1, num2, and num3, what value will the statement "num4" print? - Correct Answers ✅✅error
If all previous statements dealt only with num1, num2, and num3, what value will the statement "num4" print? - Correct Answers ✅✅error What symbol at the end of a statement suppresses printing of the result? - Correct Answers ✅✅; (semicolon) Test your understanding of what will be output to the command window as a result of entering the following lines.
X = 14; Y = 2, Z = 5 Only X will display. Only Y and Z will display. None of the above. - Correct Answers ✅✅Only Y and Z will display. The semicolon suppresses the output of X, commas do not suppress output.
Matt should use "A =6; B = 9, C = A + B;" instead. - Correct Answers ✅✅Matt should use "A = 6, B = 9; C = A + B" instead. X = 39; Y = 41, Z = X + 17 The statement results in an error. Only Y is displayed. Only Y and Z are displayed. - Correct Answers ✅✅only Y and Z displayed Matlab challenge activities Multiply x by 2 and put the result in y. Ex: If x is 2, then output y should be 4. - Correct Answers ✅✅x=2; y=x+ A bit is a 0 or 1, interpreted from voltage.
True False - Correct Answers ✅✅true 1 is usually a higher voltage (e.g., 2.0 V), 0 is usually a lower voltage (e.g., 0 V). A processor is a circuit that executes instructions. True False - Correct Answers ✅✅true A memory is a circuit that stores one machine instruction. True False - Correct Answers ✅✅false
totalPets = 3 Write a variable assignment statement that assigns luckyNumber with 7 and suppresses the output to the command window. - Correct Answers ✅✅luckyNumber = 7; Write a variable assignment statement that assigns birdFeeders with the current value of variable stockCount, and prints the value of the variable to the command window. - Correct Answers ✅✅birdFeeders = stockCount What is the value stored in luckyNumber after these two statements execute? luckyNumber = 7; luckyNumber = 4; - Correct Answers ✅✅ 4 The second write to luckyNumber overwrites the first value written into the variable. Assume apples currently has the value 5 and oranges the value 9. What is the value stored in apples after the following statement?
apples = apples + 1; - Correct Answers ✅✅ 6 5 + 1 yields 6 Assume apples currently has the value 5 and oranges the value 9. What is the value stored in apples after the following statements? apples = oranges; oranges = oranges + 1; - Correct Answers ✅✅ 9 Write a statement, ending with "- 1;", that decreases the value stored in apples by 1. - Correct Answers ✅✅apples = apples - 1; Write two statements, the first setting apples to 7, and the second setting oranges to apples plus one. Terminate each statement with a semicolon. - Correct Answers ✅✅apples = 7; oranges = apples + 1; "apples = 7" must be done first, then "oranges = apples + 1" will store 7+1 or 8 into oranges Given x = 22 and y = 99. What are x and y after the given code?
tempVal = x; x = y; y = x; x is 99 and y is 22. x is 99 and y is 99. - Correct Answers ✅✅x is 99 and y is 99. tempVal = x; x = y; y = tempVal; x is 99 and y is 22. x is 99 and y is 99. - Correct Answers ✅✅x is 99 and y is 22. numNickels = 5 numDimes = 10
% Write a statement that assigns numCoins with numNickels + numDimes - Correct Answers ✅✅numCoins = numNickels + numDimes Given a Fahrenheit value temperatureFahrenheit, write a statement that assigns temperatureCelsius with the equivalent Celsius value. While the equation is C = 5/9 * (F - 32), as an exercise use two statements, the first of which is "fractionalMultiplier = 5/9;". 77 degrees fahrenheit % Write a statement that assigns fractionalMultiplier with 5/ % Modify the statement below to convert Fahrenheit to Celsius, % assigning temperatureCelsius with the Celsius value - Correct Answers ✅✅temperatureCelsius = (5/9) * (77 - 32) = 25 % Write a statement that assigns myExamScore with 82 - Correct Answers ✅✅myExamScore = 82 % Write a statement that assigns myCurvedExamScore with myExamScore + 5 - Correct Answers ✅✅myCurvedExamScore = myExamScore + 5 Which are valid identifiers?
True False - Correct Answers ✅✅false A double-precision number's range is about 10 times greater than a single-precision number's range. True False - Correct Answers ✅✅false The default MATLAB floating-point representation can represent various numbers from -1.79e+308 to +1.79e+308. - Correct Answers ✅✅true The smallest positive number that the default MATLAB floating-point representation can store is 1.1755e- True
False - Correct Answers ✅✅false Suppress the output of all assignment statements.
Write a statement that assigns the double precision floating-point variable tempKelvin with 0.0. - Correct Answers ✅✅tempKelvin = 0.0; Assign celsiusVal with kelvinVal minus 273.15. - Correct Answers ✅✅celsiusVal = kelvinVal - 273.15; Using notation similar to 6.02e23 and starting with 3.1, write a statement to assign variable wrenchTorque with the value 3,125.99. - Correct Answers ✅✅wrenchTorque = 3.12599e3; Complex numbers. Assume i and j are the predefined values for the imaginary component of an imaginary number.
What is the result of numA = i * i? - Correct Answers ✅✅-
Does 2 / 2 * 3 equal 2/6? - Correct Answers ✅✅Incorrect / and * have equal precedence so are evaluated left to right, thus (2/2)3, which is 13, yielding 3. Does 2 / 3 ^2 equal 4/9? - Correct Answers ✅✅Incorrect
Exponent has higher precedence, so 2/(3^2) is 2/9. Does 2 + 3 * 4 - 4 equal 16? - Correct Answers ✅✅Incorrect
Does -4 ^ 2 equal -16? - Correct Answers ✅✅Correct ^ has higher precedence than -, so -(4^2) is -(16). Precedence rules. Select the expression whose parentheses enforce the compiler's evaluation order for the original expression. Note: Using such parentheses is preferable over relying on precedence rules. y + 2 * z - Correct Answers ✅✅y + (2 * z)