| Statistics Toolbox | Search  Help Desk |
| median | Examples See Also |
Median value of vectors and matrices.
Syntax
m = median(X)
Description
median(X) calculates the median value, which is the 50th percentile of a sample. The median is a robust estimate of the center of a sample of data, since outliers have little effect on it.
For vectors, median(x) is the median value of the elements in vector x. For matrices, median(X) is a row vector containing the median value of each column. Since median is implemented using sort, it can be costly for large matrices.
Examples
xodd = 1:5;
modd = median(xodd)
modd =
3
meven = median(xeven)
meven =
2.5000
This example shows robustness of the median to outliers.
xoutlier = [x 10000];
moutlier = median(xoutlier)
moutlier =
3
See Also
mean, std, cov, corrcoef
median is a function in MATLAB.