Skip to Main Content Skip to Search
Product Documentation

median - Median value of array

Syntax

M = median(A)
M = median(A,dim)

Description

M = median(A) returns the median values of the elements along different dimensions of an array. A should be of type single or double.

If A is a vector, median(A) returns the median value of A.

If A is a matrix, median(A) treats the columns of A as vectors, returning a row vector of median values.

If A is a multidimensional array, median(A) treats the values along the first nonsingleton dimension as vectors, returning an array of median values.

M = median(A,dim) returns the median values for elements along the dimension of A specified by scalar dim.

Examples

A = [1 2 4 4; 3 4 6 6; 5 6 8 8; 5 6 8 8];
median(A) 

ans =

     4     5     7     7

median(A,2)

ans =

     3
     5
     7
     7

See Also

corrcoef | cov | max | mean | min | mode | std | var

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS