# spectralFlatness

Spectral flatness for signals and spectrograms

## Syntax

## Description

specifies options using one or more name-value arguments.`flatness`

= spectralFlatness(`x`

,`f`

,`Name=Value`

)

`[`

returns the spectral arithmetic mean and spectral geometric mean. You can specify an input
combination from any of the previous syntaxes.`flatness`

,`arithmeticMean`

,`geometricMean`

] = spectralFlatness(___)

`spectralFlatness(___)`

with no output arguments plots
the spectral flatness.

If the input is in the time domain, the spectral flatness is plotted against time.

If the input is in the frequency domain, the spectral flatness is plotted against frame number.

## Examples

## Input Arguments

## Output Arguments

## Algorithms

The spectral flatness is calculated as described in [1]:

$$\text{flatness}=\frac{{\left({\displaystyle \prod _{k={b}_{1}}^{{b}_{2}}{s}_{k}}\right)}^{\frac{1}{{b}_{2}-{b}_{1}}}}{\frac{1}{{b}_{2}-{b}_{1}}{\displaystyle \sum _{k={b}_{1}}^{{b}_{2}}{s}_{k}}}$$

where

*s*is the spectral value at bin_{k}*k*.*b*_{1}and*b*_{2}are the band edges, in bins, over which to calculate the spectral spread.

## References

[1] Johnston, J. D. "Transform Coding
of Audio Signals Using Perceptual Noise Criteria." *IEEE Journal on Selected Areas
in Communications*. Vol. 6, Number 2, 1988, pp. 314–323.

## Extended Capabilities

## Version History

**Introduced in R2019a**