Module 2 Quizzes: MATLAB Arrays

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Given the equation for the area of a circle: A=πr^2 You are given a vector of radii, r. Select all of the places where a dot operator must be used : - before the * operator - No dot operators are needed - before the ^ operator

(A = pi*r.^2) before the ^ operator (always test in matlab)

You are given the following code: X=[1 4 9 16 25 36 49 64]; y = X(2) What number will be stored in y?

4

What will be the length of the array created by the following statement? 1:3:10

4 (plug into matlab then use length(1:3:10) to find length)

Given the matrix M defined below? What would be the value of x; M = [4 5 2 5; 3 2 3 5; 1 2 9 8];x = length(M); 3 [4 3] [3 4] 4

4 (plug into matlab)

Given the following matrix: M = [5 4 6; 3 1 2]; Match the code with the value it will return M(1,2) = M(2,1) = M(2) = M(1,1) =

4, 3, 3, 5

Given the following code: A = [1 2 3]; B = [4 5 6]; AB = [A; B]; How could you access the value 3 in AB? Choose all correct options. - AB(1,3) - AB(3,1) - AB(3) - AB(5)

AB(1,3) and AB(5)

The lines in the following script have been mixed up and include extra lines that aren't correct. Select the correct code in order. The code should generate the numbers from 1 to 4 and store them in an array. Then it will create a new array containing the squares of the the values in the previous array. Finally create and display a matrix of your two arrays with the original values in the top row and the squares on the bottom row. squares = list.^2; matrix = [list; squares] squares = list^2; list = linspace(1,4); list = 1:4; squares = 1^2:4^2 matrix = [list squares] Line 1 = Line 2 = Line 3 =

Line 1: list = 1:4; line 2: squares = list.^2 line 3: matrix = [list; squares]

Given the following code, what will be stored in a and b? F = [4 7 3 1 5]; [a,b] = max(F); a = 2 and b = 7 a = 7 and b = 0 a = 7 and b = 1 a = 7 and b = 2

a = 7 and b = 2 (where a is the max number in array and b is the location of the max number within the array)

What kind of an array is C? C = [2; 4; 6; 8]; Row vector Column vector Matrix

column vector

For which operation is a dot operator required? - dividing a vector by a scalar - multiplying a vector by a scalar - adding two vectors - dividing a scalar by a vector

dividing a scalar by a vector (plug examples into matlab if unsure)

T or F: All arrays are vectors.

false

The lines in the following script have been mixed up and include extra lines that aren't correct. Select the correct code in order. The code will generate an array of 6 numbers between 2 and 12.It will display the 3rd item in the array. Then it will display the average value in the array. numbers(3); average(numbers) numbers =2:6:12; numbers(3) numbers = linspace(2,12, 6); numbers(2) mean(numbers) Line 1 = Line 2 = Line 3 =

line 1 : numbers = linspace(2,12, 6); line 2: numbers(3) line 3: mean(numbers)

Which command would create an array of 15 equally spaced points between 0 and 30? [0:15:30] linspace(0,15,30) [0:30:15] linspace(0,30,15)

linspace(0,30,15)

T or F: Given the following code: y=[2 5 -19 4 -100 63]; z=length(y); The value stored in z is 6.

true

T or F: x=[1 2 3 4 5] x is an example of a row vector

true

T or F: All matrices are arrays.

true

T or F: All vectors are arrays

true


Set pelajaran terkait

unit 1 <welcome to Singapore) workbook pagg6 quzlet (sentences)

View Set

MKTG 351 Ch. 16-20 (Ole Miss, Sam Cousley)

View Set

Chapter 11 Compensating Executives

View Set

Equations of lines through 2 points

View Set