Median computation (★) - MATLAB Cody - MATLAB Central

Problem 45788. Median computation (★)

Difficulty:Rate

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

70.54% Correct | 29.46% Incorrect
Last Solution submitted on Dec 31, 2024

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8

Problem Recent Solvers88

Suggested Problems

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!