# med {#med}

## Syntax {#syntax}

`med(X)`

## Arguments {#arguments}

**X** is a scalar/vector/matrix.

## Details {#details}

If *X* is a vector, return the median of all the elements in *X*.

If *X* is a matrix, calculate the median of each column of *X* and return a vector.

As with all aggregate functions, null values are not included in the calculation.

Please note that the data type of the result is always DOUBLE.

## Examples {#examples}

```
x=3 6 1 5 9;
med x;
// output: 5

m=matrix(1 2 10, 4 5 NULL);
m;
```

|\#0|\#1|
|---|---|
|1|4|
|2|5|
|10||

```
med m;
// output: [2,4.5]
```

Related center data tendency functions: [mean](mean.md) and [mode](mode.md)

