162k views
3 votes
Suppose the MATLAB variable exampleArray is defined by: exampleArray = [4, 6, 10; 11, 7, 6; 0, -1, -4]; Click on the array that shows the results of the MATLAB command: x = median(exampleArray, 2)

Options:
A) [4; 7; -1]
B) [10; 6; 0]
C) [6; 7; -1]
D) [6; 7; 0]

1 Answer

2 votes

Final answer:

The median of each row of the exampleArray after applying the MATLAB command 'median(exampleArray, 2)' is [6; 7; -1], which corresponds to option C.

Step-by-step explanation:

The MATLAB command x = median(exampleArray, 2) calculates the median of each row of the exampleArray. When the second argument is 2, the function operates across the rows. Let's calculate the median for each row:

  • Row 1: [4, 6, 10] - Median is 6
  • Row 2: [11, 7, 6] - Median is 7
  • Row 3: [0, -1, -4] - Median is -1

Therefore, the resulting array x after running the command will be:

[6;7;-1]

This matches option C) [6; 7; -1] which is the correct answer to the student's question.

User Torrent Lee
by
7.6k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.