Docsity

MATLAB Basic Programming Exam: Questions and Answers, Exams of Nursing

Toggle sidebar
bg1
MATLAB Basic Programming Exam
Question & Answers 2024
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:2
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:11
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:8
How would you access the first twelve elements for y? - Correct
Answers ✅✅y = (1:12);
x(1:12)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download MATLAB Basic Programming Exam: Questions and Answers and more Exams Nursing in PDF only on Docsity!

Question & Answers 2024

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)

Question & Answers 2024

OR

y = (1:12); x(1:12) How would you access the 1st four multiples of 3 specified in a vector?

  • Correct Answers ✅✅y([3 6 9 12]) Write a statement transposing x - Correct Answers ✅✅x' Write two statements that notes the difference in tranpose of z - Correct Answers ✅✅z' and z.' Elementary functions in MATLAB Use the following few commands (a script) to make a plot. The evaluation of v=cos(u) creates a vector whose elements are: v(k) = cos(u(k)) where k = 1, 2, ...n - Correct Answers ✅✅n = anu number; u = linspace(0, 2pin); v = cos(u);

Question & Answers 2024

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

Question & Answers 2024

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.

Question & Answers 2024

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.

Question & Answers 2024

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

Question & Answers 2024

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?

Question & Answers 2024

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?

Question & Answers 2024

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

Question & Answers 2024

% 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?

Question & Answers 2024

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

Question & Answers 2024

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 ✅✅-

Question & Answers 2024

  1. e
  2. inf - Correct Answers ✅✅ 3 Write a statement that assigns circleArea with the circle's area given circleRadius - Correct Answers ✅✅circleRadius = 5 % Modify to use built-in math constant pi. circleArea = picircleRadiuscircleRadius Evaluating expressions using precedence rules. Note: This activity omits parentheses to test knowledge of precedence rules. But programmers should use parentheses to make evaluation order explicit.

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

Question & Answers 2024

Exponent has higher precedence, so 2/(3^2) is 2/9. Does 2 + 3 * 4 - 4 equal 16? - Correct Answers ✅✅Incorrect

  • has higher precedence, so 2 + 12 - 4 is 10. Does 2 ^ 3 ^ 2 equal 64? - Correct Answers ✅✅Correct The power operators evaluate left to right, so (2^3)^2 or 8^2, which is

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)