131k views
5 votes
Suppose the MATLAB variable exampleArray is defined by:

exampleArray = [4, 6, 10; 11, 7, 6; 0, -1, -4];
Which array shows the results of the MATLAB command: x = mean(exampleArray, 2)?

Options:
A) [5, 8, -1]
B) [6, 8, -2]
C) [6.6667; 8; -1.6667]
D) [7.5; 8; -2.5]

User Raukodraug
by
7.9k points

1 Answer

6 votes

Final answer:

The MATLAB function 'mean' with a second argument of 2 calculates the mean across each row. For the given matrix, it results in a column vector with the means of each row. The correct answer is option C) [6.6667; 8; -1.6667].

Step-by-step explanation:

The MATLAB command mean(exampleArray, 2) computes the mean of each row of exampleArray. Since exampleArray is a 3x3 matrix, the mean is calculated for each of the three rows:

  • Mean of [4, 6, 10] is (4+6+10)/3 = 6.6667
  • Mean of [11, 7, 6] is (11+7+6)/3 = 8
  • Mean of [0, -1, -4] is (0-1-4)/3 = -1.6667

Therefore, the resulting array x will be a column vector (because we used the second dimension in the mean function). Thus, option C) [6.6667; 8; -1.6667] is the correct answer.

User Arcanox
by
7.8k points