Main Content

datastats

Data statistics

Syntax

xds = datastats(x)
[xds,yds] = datastats(x,y)

Description

xds = datastats(x) returns statistics for the column vector x to the structure xds. Fields in xds are listed in the table below.

Field

Description

num

The number of data values

max

The maximum data value

min

The minimum data value

mean

The mean value of the data

median

The median value of the data

range

The range of the data

std

The standard deviation of the data

[xds,yds] = datastats(x,y) returns statistics for the column vectors x and y to the structures xds and yds, respectively. xds and yds contain the fields listed in the table above. x and y must be of the same size.

Examples

Compute statistics for the census data in census.mat:

load census
[xds,yds] = datastats(cdate,pop)
xds = 
       num: 21
       max: 1990
       min: 1790
      mean: 1890
    median: 1890
     range: 200
       std: 62.048
yds = 
       num: 21
       max: 248.7
       min: 3.9
      mean: 85.729
    median: 62.9
     range: 244.8
       std: 78.601

Tips

If x or y contains complex values, only the real parts are used in computing the statistics. Data containing Inf or NaN are processed using the usual MATLAB® rules.

Version History

Introduced before R2006a