Harmonic mean

`m = harmmean(X)`

calculates the harmonic mean of a
sample. For vectors, `harmmean(X)`

is the harmonic mean of the elements
in `X`

. For matrices, `harmmean(X)`

is a row vector
containing the harmonic means of each column. For *N*-dimensional arrays,
`harmmean`

operates along the first nonsingleton dimension of
`X`

.

`m = harmmean(X,'all')`

returns the harmonic mean of all elements of
`X`

.

`m = harmmean(X,dim)`

takes the harmonic mean along the operating
dimension `dim`

of `X`

.

`m = harmmean(X,vecdim)`

returns the harmonic mean over the
dimensions specified in the vector `vecdim`

. Each element of
`vecdim`

represents a dimension of the input array `X`

.
The output `m`

has length 1 in the specified operating dimensions. The
other dimension lengths are the same for `X`

and `m`

. For
example, if `X`

is a 2-by-3-by-4 array, then ```
harmmean(X,[1
2])
```

returns a 1-by-1-by-4 array. Each element of the output array is the
harmonic mean of the elements on the corresponding page of `X`

.

specifies whether to exclude `m`

= harmmean(___,`nanflag`

)`NaN`

values from the calculation, using any
of the input argument combinations in previous syntaxes. By default,
`harmmean`

includes `NaN`

values in the calculation
(`nanflag`

has the value `'includenan'`

). To exclude
`NaN`

values, set the value of `nanflag`

to
`'omitnan'`

.

When

`harmmean`

computes the harmonic mean of an array containing`0`

, the returned value is`0`

.