Given a vector of values, compute the median. The median is defined as the middle value in a set of sorted data. Thus, if
x = [ 3 1 5 2 4 ]
then the sorted data will be
[ 1 2 3 4 5 ]
and the middle value or median is 3. If x has an even number of elements, such as
x = [ 3 6 1 5 2 4 ]
Then there are 2 middle values in the sorted data and the median is average of the 2. Thus, sorted data is
[ 1 2 3 4 5 6]
and the median is 3.5.
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers89
Suggested Problems
-
Find the alphabetic word product
3460 Solvers
-
Back to basics 22 - Rotate a matrix
937 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
13754 Solvers
-
07 - Common functions and indexing 3
427 Solvers
-
Create a vector with n repeated values of a number x (★★)
113 Solvers
More from this Author52
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!