MATLAB QUIZ 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

Given an array A = [1 2 3; 4 5 6; 7 8 9], what is the result of the following command A(1:2,1:2)?

[1,2;4,5]

What is the value of c after executing the following commands? a = [3 0 8]; b = [5 0 2]; c = a.*b;

[15 0 16]

Given originalArray = [1, 10, 20, 40], what is the value of newArray after the following command? newArray = originalArray * 2;

[2, 20, 40, 80]

What command will construct an array that decreases by 3 starting from 50 and ending at 32?

[50:-3:32]

What is the value of the array anotherArray = [3:2:10]; after executing anotherArray([2:3]) = [-1, -2];

anotherArray = 3 -1 -2 9

Given theArray = [3, 5, 6, 10, 2, 1], which of the following commands create an array with 3rd and 4th elements of theArray. 1. All of the above 2. newArray = theArray([3,4]); 3. newArray = [0, 0];newArray(1) = theArray(3);newArray(2) = theArray(4); 4. newArray = theArray(3:4);

1

What is the starting index of an array in MATLAB?

1

What is the result of the following commands? x = [1:3.4; -6:3.5:0.5]; size(x)

Error

Which of the following examples concatenates column vectors trialOne, trialTwo, and trialThree into a new column vector allTrials?

allTrials = [trialOne; trialTwo; trialThree]

Consider the following array: dataTrial1 = [28.3, 29.1, 28.4, 29.0, 28.6, 28.7, 28.7, 28.8]; What is the value of the following command? dataTrial1(end-5:end-2)

ans = 28.4000 29.0000 28.6000 28.7000

Consider the following array: dataTrial1 = [28.3, 29.1, 28.4, 29.0, 28.6, 28.7, 28.7, 28.8]; What is the value of the following command? dataTrial1([6, 2, 7])

ans = 28.7000 29.1000 28.7000

Consider the following array: dataTrial1 = [28.3, 29.1, 28.4, 29.0, 28.6, 28.7, 28.7, 28.8]; What is the value of the following command? dataTrial1(2:4)

ans = 29.1000 28.4000 29.0000

Which of the following is NOT an element-wise operation? x * y x - y x + y x ./ y

x * y

Which of the following statement is NOT true about a scalar variable? A scalar variable contains a single element. A scalar variable is compatible with arrays in element-wise arithmetic. A scalar variable is an array in MATLAB. A scalar variable has zero as one of its dimension.

A scalar variable has zero as one of its dimension.

Consider the following array: dataTrial1 = [28.3, 29.1, 28.4, 29.0, 28.6, 28.7, 28.7, 28.8]; What is the value of the following command? dataTrial1(7:-2:2)

ans = 28.7000 28.6000 28.4000

What is the value of timeLapsed after executing the following commands? timeLapsed = [15, 18, 13, 20, 14, 20, 21, 22, 17]; timeLapsed(9:12) = 11;

15 18 13 20 14 20 21 22 11 11 11 11

What is the size of the following array? v = [17; 3; 9; 19; 16; 20; 14];

7x1

What is the value of the array initialArray = [1, 2, 3, 4] after executing i = 7; initialArray(i) = 2;

initialArray = 1 2 3 4 0 0 2

What statement does NOT transpose the row array pounds = [21, 14, 19]; into a column array? pounds_transpose = pounds" pounds_transpose = transpose(pounds) pounds_transpose = pounds(:) pounds_transpose = pounds'

pounds_transpose = pounds"

What are the dimensions of the following array? A =2 2 5 6 4 3 8 2 4 1 2 6 8 5 3

3x5

Given an array a = 1:100, which of the following command adds one to all elements at odd indices (not divisible by 2, e.g. 1, 3, 5, 7, ...)?

a(1:2:end) = a(1:2:100) + 1;

sqrt is a built-in function that calculates the square root of its input argument. What is the result of the following command? numArray = [4:9].^2; sqrt(numArray)

ans = 4 5 6 7 8 9

What is the correct way to access the fourth element of the array thisArray?

thisArray(4)

What is the result of the following command? u = 10:1;

u becomes an empty vector.


Conjuntos de estudio relacionados

HEALTH ASSESSMENT TTL's Day 6-10

View Set

Chapter 5. Cost-Volume-Profit Relationships

View Set