# Extract Spectral Features

Interactively extract spectral fault band metrics in the Live Editor

## Description

The **Extract Spectral Features** task lets you
interactively extract spectral fault band metrics. The task helps with analyzing and
understanding spectral data. Using a comprehensive interface, you can add components to
represent various bearings, gear meshes, or other parts of your hardware setup. As you set the
physical parameters of these components, the **Extract Spectral
Features** Live Editor task plots fault frequency bands at the characteristic
frequencies of the components. You can overlay power spectrum data on the fault band plot to
associate various peaks in the data with the components' characteristic frequencies. These
correlations can make fault detection and fault isolation easier, as changes in the power
spectrum data can easily be traced back to the physical components causing them. In addition
to a plot of the characteristic frequencies and the power spectrum data, the task generates
spectral metrics of the data within each characteristic frequency band. The output metrics
table, which contains the peak amplitude, peak frequency, and band power of each band, aids in
characterizing potential mechanical faults. The task automatically generates MATLAB^{®} code for your live script. For more information about Live Editor tasks in
general, see Add Interactive Tasks to a Live Script.

## Open the Task

To add the **Extract Spectral Features** task to a live
script in the MATLAB Editor:

On the

**Live Editor**tab, select**Task**>**Extract Spectral Features**.In a code block in your script, type a relevant keyword, such as

`fault bands`

or`metrics`

. Select`Extract Spectral Features`

from the suggested command completions.

## Parameters

**Select Power Spectrum Data**

`Frequency vector`

— Frequencies corresponding to power spectrum data

vector

Select a vector of frequencies from the MATLAB workspace that correspond to your power spectrum data.

`Power spectrum magnitude`

— Power spectrum magnitude data

vector

Select a vector containing the power spectrum magnitudes from the MATLAB workspace.

**Configure Components**

`Add component`

— Bearing, gear mesh, or custom hardware representation

'`Bearing`

' | '`Gear mesh`

' | '`Custom`

'

Choose between adding a bearing, gear mesh, or custom component. You can name your
component and then click the **Add** button. You can set the physical
characteristics of these components using their corresponding parameters. The
**Extract Spectral Features** Live Editor task plots
fault frequency bands at the characteristic frequencies of the components.

**Bearing Component Parameters**

`Enable component`

— Toggle to enable or disable component for spectral metrics computation

`on`

(default) | `off`

You can toggle this option to enable or disable the component from being included in
the spectral metrics computation. Disabling the component also removes its fault bands
from the plot. Use the **Delete** button to permanently remove a
component.

`Number of balls`

— Number of balls or rollers in bearing

10 (default) | positive integer

Specify the number of rolling elements in the bearing as a positive integer.

`Pitch diameter`

— Pitch diameter of bearing

35 (default) | positive scalar

Specify the pitch diameter of the bearing as a positive scalar. The pitch diameter is the diameter of the circle that the center of the ball or roller travels during the bearing rotation.

`Rotational speed`

— Rotational speed of shaft or inner race of bearing

60 (default) | positive scalar

Specify the rotational speed of the shaft or inner race of the bearing as a positive
scalar. The rotational speed is the fundamental frequency around which the
**Extract Spectral Features** live task generates the
fault frequency bands. The units must be consistent with the unit of the frequency
vector.

`Contact angle`

— Bearing contact angle

0 (default) | non-negative scalar

Specify the contact angle in degrees between a plane perpendicular to the ball or roller axis and the line joining the two raceways.

`Ball diameter`

— Diameter of ball or roller

10 (default) | positive scalar

Specify the diameter of the ball or roller in the bearing as a positive scalar.

`Harmonics`

— Harmonics of fundamental frequency

`1`

(default) | vector of positive integers

Specify the harmonics of the fundamental frequency to be included in the plot and in the spectral metrics computation.

`Sidebands`

— Sidebands around fundamental frequency and its harmonics to be included

`0`

(default) | vector of nonnegative integers

Specify the sidebands around the fundamental frequency and its harmonics to be included in the plot and in the spectral metrics computation.

`Domain`

— Units of fault band frequencies

`'frequency'`

(default) | `'order'`

Specify the units of the fault band frequencies as either
`'frequency'`

or `'order'`

. Select:

`'frequency'`

if you have the fault bands in the same units as the**Rotational speed**.`'order'`

if you have the fault bands as a number of rotations relative to the inner race rotation**Rotational speed**.

`Band width`

— Width of frequency bands centered at nominal fault frequencies

auto (default) | positive scalar

Specify the width of the frequency bands centered at the nominal fault frequencies
as a positive scalar. Uncheck the **Auto** option to specify the width
value manually.

**Gear Mesh Component Parameters**

`Enable component`

— Toggle to enable or disable component for spectral metrics computation

`on`

(default) | `off`

You can toggle this option to enable or disable the component from being included in
the spectral metrics computation. Disabling the component also removes its fault bands
from the plot. Use the **Delete** button to permanently remove a
component.

`Input gear teeth`

— Number of teeth on input gear

10 (default) | positive integer

Specify the number of teeth on the input gear as a positive integer.

`Output gear teeth`

— Number of teeth on output gear

40 (default) | positive integer

Specify the number of teeth on the output gear as a positive integer.

`Rotational speed`

— Rotational speed of input gear

60 (default) | positive scalar

Specify the rotational speed of the input gear as a positive scalar. The rotational
speed is the fundamental frequency around which the **Extract Spectral
Features** live task generates the fault frequency bands. The units
must be consistent with the unit of the frequency vector.

`Harmonics`

— Harmonics of fundamental frequency to be included

`1`

(default) | vector of positive integers

Specify the harmonics of the fundamental frequency to be included in the plot and in the spectral metrics computation.

`Sidebands`

— Sidebands around fundamental frequency and its harmonics to be included

`0`

(default) | vector of nonnegative integers

Specify the sidebands around the fundamental frequency and its harmonics to be included in the plot and in the spectral metrics computation.

`Domain`

— Units of fault band frequencies

`'frequency'`

(default) | `'order'`

Specify the units of the fault band frequencies as either
`'frequency'`

or `'order'`

. Select:

`'frequency'`

if you have the fault bands in the same units as the**Rotational speed**.`'order'`

if you have the fault bands as a number of rotations relative to the**Rotational speed**.

`Band width`

— Width of frequency bands centered at nominal fault frequencies

auto (default) | positive scalar

Specify the width of the frequency bands centered at the nominal fault frequencies
as a positive scalar. Uncheck the **Auto** option to specify the width
value manually.

**Custom Component Parameters**

`Enable component`

— Toggle to enable or disable component for spectral metrics computation

`on`

(default) | `off`

You can toggle this option to enable or disable the component from being included in
the spectral metrics computation. Disabling the component also removes its fault bands
from the plot. Use the **Delete** button to permanently remove a
component.

`Frequency`

— Fundamental frequency of interest

60 (default) | positive scalar

Specify the fundamental frequency of interest as a positive scalar. The
**Extract Spectral Features** live task constructs the
fault frequency bands around the fundamental frequency. For instance, to construct fault
bands for a faulty induction motor, the mains frequency of 60 Hz is the fundamental
frequency of interest. Similarly, to generate fault bands for a faulty gear train, the
input shaft frequency is the fundamental frequency.

`Harmonics`

— Harmonics of fundamental frequency to be included

`1`

(default) | vector of positive integers

Specify the harmonics of the fundamental frequency to be included in the plot and in the spectral metrics computation.

`Sidebands`

— Sidebands around fundamental frequency and its harmonics to be included

`0`

(default) | vector of nonnegative integers

Specify the sidebands around the fundamental frequency and its harmonics to be included in the plot and in the spectral metrics computation.

`Separation type`

— Type of separation between successive sidebands

`'additive'`

(default) | `'multiplicative'`

Specify the type of separation between successive sidebands as either
`'additive'`

or `'multiplicative'`

. Select:

`'additive'`

, to set the separation between successive sidebands to a value of 0.1 times the`F1`

frequency value, where`F1`

is the distance of the first sideband from the fundamental frequency.`'multiplicative'`

, to set the separation between successive sidebands proportional to both the harmonic order and the sideband value.

`Separation`

— Separation value between successive sidebands

`Auto`

(default) | positive scalar

Specify the separation value between successive sidebands as a positive scalar.
Uncheck the **Auto** option to specify the separation value
manually.

`Band width`

— Width of frequency bands centered at nominal fault frequencies

auto (default) | positive scalar

Specify the width of the frequency bands centered at the nominal fault frequencies
as a positive scalar. Uncheck the **Auto** option to specify the width
value manually.

`Folding`

— Toggle to specify whether negative nominal fault frequencies are folded about frequency origin

`off`

(default) | `on`

Toggle this option to specify whether negative nominal fault frequencies are folded
about the frequency origin. If you turn **Folding**
`on`

, then the **Extract Spectral
Features** live task folds the negative nominal fault frequencies about
the frequency origin by taking their absolute values such that the folded fault bands
always fall in the positive frequency intervals. The folded fault bands are computed as $$\left[\text{max}\left(0,\text{}\left|F\right|-\frac{W}{2}\right),\text{}\left|F\right|+\frac{W}{2}\right]$$, where *W* is the **Band width**
and *F* is the **Frequency**.

**Display Results**

`Spectral metrics`

— Toggle to enable or disable display of spectral metrics

`off`

(default) | `on`

Toggle this option to enable or disable the display of spectral metrics. When the
option is checked, then the **Extract Spectral Features**
live task displays the metrics as a `1`

-by-`N`

table,
where `N = 3*size((F+S),1)+1`

. That is, it displays three metrics per
frequency range and the total band power over the frequency range.

The live task returns the following spectral metrics:

`Peak Amplitude`

— Peak amplitude value for each specified frequency range.`Peak Frequency`

— Peak frequency value for each specified frequency range.`Band Power`

— Average power of each specified frequency range. For more information on band power, see`bandpower`

.`Total Band Power`

— Sum of individual band powers for the set of specified frequency ranges.

## Version History

**Introduced in R2021a**

## See Also

`faultBands`

| `gearMeshFaultBands`

| `bearingFaultBands`

| `faultBandMetrics`