102k views
3 votes
Given the MATLAB variable: C = [ 6,8,10; 12,4,11 ] E = max(C, [ ], 2)

Options:
A) [10; 12]
B) [10, 12]
C) [10, 11]
D) [10; 11]

1 Answer

5 votes

Final answer:

The MATLAB function max(C, [], 2) calculates the maximum value in each row of matrix C. The result is a column vector with the maximum values from each row, which in this case is [10; 12], making Option A the correct answer.

Step-by-step explanation:

The student is asked to determine the output of the MATLAB variable E which is the result of applying the max function to the matrix C along the second dimension. The MATLAB code snippet is E = max(C, [], 2). In MATLAB, this line calculates the maximum value of each row of matrix C, since the second argument as empty array [] indicates the direction along which the maximum value is to be found, and the number 2 refers to the second dimension (rows) of the matrix.

Matrix C is a 2x3 matrix with the first row as [6,8,10] and the second row as [12,4,11]. The max value of the first row is 10, and for the second row it is 12. Therefore, E would be a 2x1 column vector with these max values. The correct answer is Option A) [10; 12].

User Thedanotto
by
7.1k points