mad

Compute mean or median absolute deviation values.

Syntax

m=mad(x)

m=mad(x,opt)

m=mad(x,opt,dim)

Inputs

x
Data sample.
Type: double
Dimension: vector | matrix
opt
The deviation option (0 = mean, 1 = median).
Default: 0.
Type: integer
Dimension: scalar
dim
Dimension on which to perform the calculation.
Default: first non-singleton dimension.
Type: integer
Dimension: scalar

Outputs

m
Mean or median deviation.

Examples

Vector example with median deviation:

x = [9.3, 10.6, 11.9, 13.3, 15.1, 18.2];
m=mad(x,1)
m = 2.25
Matrix example with median deviation:
x = [9.3, 4.8; 10.6, 6.6; 11.9, 8.0; 13.3, 9.3; 15.1, 10.6; 18.2, 11.9];
m=mad(x,1)
m = [Matrix] 1 x 2
2.25000  2.00000