signalTimeFrequencyFeatureExtractor
The Transform property has changed. For more information, see Version History.
Description
Use a signalTimeFrequencyFeatureExtractor object to extract time-frequency
features from a signal. You can use the extracted features to train a machine
learning model or a deep learning network.
Creation
Syntax
Description
creates a sFE = signalTimeFrequencyFeatureExtractorsignalTimeFrequencyFeatureExtractor object with default property values.
sets property values of the sFE = signalTimeFrequencyFeatureExtractor(PropertyName=Value)signalTimeFrequencyFeatureExtractor object. For
example,
sFE = signalTimeFrequencyFeatureExtractor( ...
FrameSize=30,SampleRate=10,SpectralKurtosis=true)signalTimeFrequencyFeatureExtractor object that partitions a signal into frames of 30 samples
each and a rate of 10 Hz to extract the spectral kurtosis feature from the spectrogram of
each frame.Properties
Main Properties
Number of samples per frame, specified as a positive integer. The
object divides the signal into frames of the specified length
and extracts features for each frame. If you do not specify
FrameSize, or if you specify
FrameSize as empty, the object
extracts features for the whole signal.
Data Types: single | double
Number of samples between the start of frames, specified as a positive integer. The frame rate
determines the distance in samples between the starting points of frames. If you specify
FrameRate, then you must also specify FrameSize.
If you do not specify FrameRate or
FrameOverlapLength, then the object assumes
FrameRate to be equal to FrameSize.
Note
You cannot specify FrameRate and
FrameOverlapLength simultaneously.
Data Types: single | double
Number of overlapping samples between consecutive frames, specified as a positive
integer. FrameOverlapLength must be less than or equal to the frame
size. If you specify FrameOverlapLength, then you must also specify
FrameSize.
Note
You cannot specify FrameOverlapLength and
FrameRate simultaneously.
Data Types: single | double
Input sample rate, specified as a positive scalar in hertz.
If you do not specify SampleRate, the extract function of the object assumes the signal
sampling rate as 2π Hz.
Data Types: single | double
Rule to handle incomplete frames, specified as one of these:
"drop"— Drop the incomplete frame and do not use it to compute features."zeropad"— Zero-pad the incomplete frame and use it to compute features.
This rule applies when the current frame size is less than the specified
FrameSize property.
Data Types: char | string
Format of the signal features generated by the extract
function, specified as one of these:
"matrix"— Columns correspond to feature values."table"— Each table variable corresponds to a feature value.
Note
You can generate features for multiple signals at once by specifying a datastore
object input in the extract function. In this case, extract returns
a cell array where each member corresponds to a feature matrix or table from a
signal member of the datastore. The format of the generated features in each member
follows the format specified in FeatureFormat.
Data Types: char | string
Time-frequency analysis methods to use for feature extraction, specified as a timeFrequencyFeatureTransformOptions object or a struct array.
Note
The Transform property will no longer support string
scalars or character vectors in a future release. Instead, specify
Transform as a
timeFrequencyFeatureTransformOptions object or a
struct array.
The signalTimeFrequencyFeatureExtractor object uses the Transform
property to determine which time-frequency representation to use to extract each feature.
To specify a
timeFrequencyFeatureTransformOptionsobject orstructarray, use name-value arguments consisting of a feature and its corresponding time-frequency analysis method. (since R2026a)Example:
tfOpts = struct(TFRidges="synchrosqueezedscalogram",InstantaneousEnergy="vmd"); tfFE = signalTimeFrequencyFeatureExtractor(Transform=tfOpts,TFRidges=true,InstantaneousEnergy=true);
If you specify this property as a
structarray,signalTimeFrequencyFeatureExtractorconverts it to an equivalenttimeFrequencyFeatureTransformOptionsobject. (since R2026a)If you do not specify this property, the
signalTimeFrequencyFeatureExtractorobject uses default time-frequency analysis methods.
This table lists the time-frequency features that the signalTimeFrequencyFeatureExtractor
object supports, along with the time-frequency analysis methods you can use to extract
those features. For more information, see Analysis Methods for Time-Frequency Features.
| Features to Extract | Time-Frequency Analysis Methods |
|---|---|
SpectralKurtosisSpectralSkewnessSpectralCrestSpectralFlatnessSpectralEntropyTFRidgesInstantaneousBandwidth | "spectrogram" (default)
|"synchrosqueezedspectrogram"
| "synchrosqueezedscalogram" |
InstantaneousFrequency | "spectrogram" (default)
|"synchrosqueezedspectrogram"
| "synchrosqueezedscalogram" |
"emd" |
"vmd" | "wavelet" |
"waveletpacket" |
InstantaneousEnergy | "emd" (default) | "vmd" |
"wavelet" |
"waveletpacket" |
MeanEnvelopeEnergy | "emd" |
WaveletEntropy | "wavelet" (default) |
"waveletpacket" |
TimeSpectrumScaleSpectrum | "scalogram" |
Note
You cannot specify
FrameSize,FrameRate, orFrameOverlapLengthif both of these conditions occur:You enable either of these features:
InstantaneousFrequency,InstantaneousEnergy, orMeanEnvelopeEnergy.You set either of these analysis methods:
"emd"or"vmd".
You must have a Wavelet Toolbox™ license to extract features from the
"scalogram","synchrosqueezedscalogram","wavelet", or"waveletpacket"analysis methods.
Methods to convert feature vectors to scalar values, specified as a timeFrequencyScalarFeatureOptions object.
You can specify methods to extract scalar values from Features to Extract. Specify
scalarization methods for the feature extractor object by using the
ScalarizationMethod name-value argument or the setScalarizationMethods function.
If you specify
ScalarizationMethod, thesignalTimeFrequencyFeatureExtractorobject returns the corresponding scalar values for each feature vector using the scalarization method.To convert a feature vector to scalar feature values:
You must enable the feature for extraction by setting the feature name in the
signalTimeFrequencyFeatureExtractorobject totrue.You must specify the desired scalarization methods for each feature name using a cell array of character vectors or a string array and store the information in a
timeFrequencyScalarFeatureOptionsobject.
After that, the
extractfunction:Extracts the vectors corresponding to each enabled feature.
Takes the list of scalarization methods compiled by the object and for each method computes the corresponding scalar value.
Concatenates the vector features and the scalar features.
If you do not specify
ScalarizationMethod, thesignalTimeFrequencyFeatureExtractorobject does not perform any scalarization.
For more information about scalarization methods, see Scalarization Methods for Time-Frequency Features.
Features to Extract
Extract signal features from its representation in the time-frequency domain. Specify
the features to extract as name-value arguments
,
where featureName1=true,...,featureNameN=true, …,
featureName1 are the feature names. The
order of the arguments does not matter and you can specify them simultaneously with the
Main Properties.featureNameN
Example: sFE =
signalTimeFrequencyFeatureExtractor(InstantaneousEnergy=true,MeanEnvelopeEnergy=true)
creates a time-frequency feature extractor object to extract the instantaneous energy and
mean envelope energy from the empirical mode decomposition (EMD) transform of a
signal.
Option to extract the spectral kurtosis of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the spectral kurtosis feature, see spectralKurtosis.
Data Types: logical
Option to extract the spectral skewness of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the spectral skewness feature, see spectralSkewness.
Data Types: logical
Option to extract the spectral crest of the time-frequency signal representation,
specified as true or false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the spectral crest feature, see spectralCrest.
Data Types: logical
Option to extract the spectral flatness of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the spectral flatness feature, see spectralFlatness.
Data Types: logical
Option to extract the spectral entropy of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the spectral entropy feature, see spectralEntropy.
Data Types: logical
Option to extract the time-frequency ridges of the time-frequency signal
representation, specified as true or false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the time-frequency ridge feature, see tfridge.
Data Types: logical
Option to extract the instantaneous bandwidth of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the instantaneous bandwidth feature, see instbw.
Data Types: logical
Option to extract the instantaneous frequency of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the instantaneous frequency feature, see instfreq
or hht.
Data Types: logical
Option to extract the instantaneous energy of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the instantaneous energy feature, see hht.
Data Types: logical
Option to extract the mean energy of the upper and lower envelopes for each
intrinsic mode function (IMF) of the time-frequency signal representation, specified
as true or false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the mean-envelope energy feature, see emd.
Data Types: logical
Option to extract the wavelet entropy of the time-frequency signal representation,
specified as true or false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the wavelet entropy feature, see wentropy (Wavelet Toolbox).
Data Types: logical
Option to extract the time-averaged wavelet spectrum of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the time spectrum feature, see timeSpectrum (Wavelet Toolbox).
Data Types: logical
Option to extract the scale-averaged wavelet spectrum of the time-frequency signal
representation, specified as true or
false.
If you specify this feature as true:
The feature extractor object enables this feature for extraction.
The
extractfunction extracts this feature and concatenates it with all the other features that you enable in the feature extractor object.
For more information about the scale spectrum feature, see scaleSpectrum (Wavelet Toolbox).
Data Types: logical
Object Functions
extract | Extract time-domain, frequency-domain, or time-frequency-domain features |
generateMATLABFunction | Create MATLAB function compatible with C/C++ code generation |
getExtractorParameters | Get current parameter values of feature extractor object |
getScalarizationMethods | Get scalarization methods for domain-specific signal features |
setExtractorParameters | Set nondefault parameter values for feature extractor object |
setScalarizationMethods | Set scalarization methods for domain-specific signal features |
Examples
Extract the spectral kurtosis and instantaneous frequency from the spectrogram of a quadratic-swept chirp signal.
Generate a chirp with quadratic instantaneous frequency deviation. The chirp is sampled at 2 Hz for 60 seconds. The instantaneous frequency is 0.5 Hz at t = 0 and crosses 2 Hz at t = 60 seconds.
fs = 2*pi;
t = 0:1/fs:60;
x = chirp(t,0.5,60,2,"quadratic");Create a signalTimeFrequencyFeatureExtractor object and enable the SpectralKurtosis and InstantaneousFrequency time-frequency-domain features.
tfFE = signalTimeFrequencyFeatureExtractor( ...
SpectralKurtosis=true,InstantaneousFrequency=true)tfFE =
signalTimeFrequencyFeatureExtractor with properties:
Properties
FrameSize: []
FrameRate: []
SampleRate: []
IncompleteFrameRule: "drop"
FeatureFormat: "matrix"
Transform: [1×1 timeFrequencyFeatureTransformOptions]
ScalarizationMethod: [1×1 timeFrequencyScalarFeatureOptions]
Enabled Features
SpectralKurtosis, InstantaneousFrequency
Disabled Features
SpectralSkewness, SpectralCrest, SpectralFlatness, SpectralEntropy, TFRidges, InstantaneousBandwidth
MeanEnvelopeEnergy, InstantaneousEnergy, WaveletEntropy, TimeSpectrum, ScaleSpectrum
Extract the features from the chirp signal. Reshape the result into the number of features extracted. Plot the features.
features = extract(tfFE,x); featuresRows = reshape(features,[],2); stackedplot(featuresRows,"*",... DisplayLabels=["Spectral Kurtosis" "Instantaneous Frequency"]) grid on

Set up a three-signal signalDatastore object and a signalTimeFrequencyFeatureExtractor object. Extract the spectral entropy and time-frequency ridges to the signals.
Create a signalDatastore object with three oscillating signals sampled at 5000 Hz for three seconds.
Fs = 5000;
t = 0:1/Fs:3;
members = {chirp(t,0,t(end),Fs/4); ...
2*chirp(t,Fs/20,t(end),Fs/2,"quadratic",[],"convex"); ...
vco(sin(2*pi*t),[0.1 0.4]*Fs,Fs)};
sds = signalDatastore(members,SampleRate=Fs,OutputDataType="single");Create a signalTimeFrequencyFeatureExtractor object. Specify a sample rate. Enable the spectral entropy and time-frequency ridges as features to extract.
tfFE = signalTimeFrequencyFeatureExtractor( ...
SampleRate=Fs,SpectralEntropy=true,TFRidges=true);Set up the extractor parameters for a signalTimeFrequencyFeatureExtractor object. Specify the range between Fs/5 and Fs/2.5 to extract the spectral entropy. Set the penalty parameter to zero to extract the time-frequency ridges.
setExtractorParameters(tfFE,"SpectralEntropy",Range=[Fs/5 Fs/2.5]); setExtractorParameters(tfFE,"TFRidges",Penalty=0);
Extract and plot the time-frequency features for all the signals from a signalDatastore object.
[features,infoFt] = extract(tfFE,sds);
ftMatrix = cell2mat(features);
spectralEntropy = ftMatrix(:,infoFt{1}.SpectralEntropySpectrogram);
TFRidges = ftMatrix(:,infoFt{1}.TFRidgesSpectrogram);
ftNames = ["Spectral Entropy" "Time-Frequency Ridges"];
tiledlayout(numel(members),2)
for id=1:numel(members)
featureValues = {spectralEntropy(id,:) TFRidges(id,:)};
for fid = 1:numel(ftNames)
nexttile
plot(featureValues{fid})
title(ftNames(fid))
subtitle("Signal " + id)
axis tight
end
end
Specify scalarization methods to extract the scalar impulse factor and peak value of the instantaneous energy feature for an oscillating signal.
Set the impulse factor and the peak value as scalarization methods for the instantaneous energy time-frequency domain feature.
opts = scalarFeatureOptions("timefrequency", ... InstantaneousEnergy={'ImpulseFactor';'PeakValue'})
opts =
timeFrequencyScalarFeatureOptions with properties:
SpectralKurtosis: [0×0 string]
SpectralSkewness: [0×0 string]
SpectralCrest: [0×0 string]
SpectralFlatness: [0×0 string]
SpectralEntropy: [0×0 string]
TFRidges: [0×0 string]
InstantaneousBandwidth: [0×0 string]
InstantaneousFrequency: [0×0 string]
InstantaneousEnergy: [2×1 string]
MeanEnvelopeEnergy: [0×0 string]
TimeSpectrum: [0×0 string]
WaveletEntropy: [0×0 string]
ScaleSpectrum: [0×0 string]
All: [0×0 string]
Create a signalTimeFrequencyFeatureExtractor object that returns scalar values for the instantaneous energy feature from the variational mode decomposition of a signal.
tfFE = signalTimeFrequencyFeatureExtractor( ... Transform=struct("InstantaneousEnergy","vmd"), ... InstantaneousEnergy=true,ScalarizationMethod=opts);
Extract the vector and scalar features for a voltage-controlled oscillating signal.
fs = 10000; t = 0:1/fs:2; x = vco(sawtooth(2*pi*t,0.75),[0.1 0.4]*fs,fs); [features,info] = extract(tfFE,x);
Display the scalar feature values.
% Impulse Factor of the Instantaneous Energy Vector
features(info.InstantaneousEnergyVMDImpulseFactor)ans = 8.7551
% Peak Value of the Instantaneous Energy Vector
features(info.InstantaneousEnergyVMDPeakValue)ans = 1.3385
Extract the time-frequency ridges from a spectrogram using a signalTimeFrequencyFeatureExtractor object.
Load a data file containing an echolocation pulse batsignal, emitted by a big brown bat (Eptesicus fuscus) and measured with a sample rate DT of 7 microseconds. For more information, see the example Find and Track Ridges Using Reassigned Spectrogram. Thanks to Curtis Condon, Ken White, and Al Feng of the Beckman Center at the University of Illinois for the bat data and permission to use it in this example.
load batsignalCreate a MATLAB® timetable using the signal and the time information.
t = (0:length(batsignal)-1)*DT; sg = timetable(seconds(t)',batsignal);
Create an object to extract time-frequency ridges from the spectrogram of a signal.
Fs = 1/DT; sfe = signalTimeFrequencyFeatureExtractor(SampleRate=Fs,TFRidges=true);
Set the leakage, the time resolution, and the overlap percent parameters for the spectrogram analysis method.
lk = 0.9; tRes = 0.00028; % seconds oPer = 85; setExtractorParameters(sfe,"spectrogram", ... Leakage=lk,TimeResolution=tRes,OverlapPercent=oPer);
Set the number of ridges, number of frequency bins, and penalty parameters for the time-frequency ridges feature.
nRidges = 3; setExtractorParameters(sfe,"TFRidges", ... NumRidges=nRidges,NumFrequencyBins=128,Penalty=0.01);
Extract and plot the time-frequency ridges.
tfRidges = reshape(extract(sfe,sg),[],nRidges); tStamps = seconds(tRes/2+(1-oPer/100)*tRes*(0:length(tfRidges)-1)); plot(tStamps,tfRidges/1000) xlabel("Time") ylabel("Frequency (kHz)")

Extract the instantaneous frequency of a signal using the wavelet synchrosqueezed transform (WSST), the time-averaged wavelet spectrum using the continuous wavelet transform (CWT), and the wavelet entropy using the maximal overlap discrete wavelet transform (MODWT).
Load an ECG signal corresponding to record 200 of the MIT-BIH Arrhythmia Database [1]. The workspace variable ecgsig contains the signal, and the variable tm contains the sample times. The sample rate is approximately 400 Hz.
load mit200
Fs = 400;The signal has 10,000 samples. Reshape the signal into a 1000-by-10 matrix. Each column represents one channel in a multichannel signal. Create a signalDatastore object from the matrix.
ecgsig = reshape(ecgsig,[],10); ecgsig = num2cell(ecgsig,1); sds = signalDatastore(ecgsig,SampleRate=Fs);
Set the mean and standard deviation as scalarization methods for the wavelet entropy feature.
opts = scalarFeatureOptions("timefrequency", ... WaveletEntropy=["Mean" "StandardDeviation"]);
Create a signalTimeFrequencyFeatureExtractor object that returns:
Wavelet entropy and the scalar values specified in
optsInstantaneous frequency from a WSST
Time-averaged spectrum from a CWT
You can extract instantaneous frequency from a time-frequency signal representation created using methods such as the short-time Fourier transform ("spectrogram"), empirical mode decomposition ("emd"), and the maximal overlap discrete wavelet packet transform ("waveletpacket"). Set the time-frequency analysis method for the instantaneous frequency feature to "synchrosqueezedscalogram". The CWT is the only analysis method you can use to extract the time-averaged wavelet spectrum. The signalTimeFrequencyFeatureExtractor object uses the MODWT, the default analysis method of the wentropy function, to extract the wavelet entropy.
tf = timeFrequencyFeatureTransformOptions( ... "InstantaneousFrequency","synchrosqueezedscalogram"); tfFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tf, ... InstantaneousFrequency=true, ... WaveletEntropy=true, ... TimeSpectrum=true, ... ScalarizationMethod=opts);
Extract the features from all the signals.
data = read(sds);
[features,info] = extract(tfFE,sds);
ftMatrix = cell2mat(features);
instFrq = ftMatrix(:,info{1}.InstantaneousFrequencySynchroSqueezedScalogram);
timeSpect = ftMatrix(:,info{1}.TimeSpectrumScalogram);
waveEnt = ftMatrix(:,info{1}.WaveletEntropyWavelet);
waveEntMean = ftMatrix(:,info{1}.WaveletEntropyWaveletMean);
waveEntStd = ftMatrix(:,info{1}.WaveletEntropyWaveletStandardDeviation);For each signal, compute the mean and standard deviation directly from the extracted wavelet entropy. Confirm they are equal to the extracted scalar values.
[mean(waveEnt,2) waveEntMean]
ans = 10×2
0.7675 0.7675
0.7941 0.7941
0.7533 0.7533
0.7465 0.7465
0.8055 0.8055
0.8141 0.8141
0.8048 0.8048
0.7833 0.7833
0.7999 0.7999
0.7910 0.7910
[std(waveEnt,0,2) waveEntStd]
ans = 10×2
0.1714 0.1714
0.1258 0.1258
0.2063 0.2063
0.1945 0.1945
0.1367 0.1367
0.1123 0.1123
0.1235 0.1235
0.1228 0.1228
0.1123 0.1123
0.1168 0.1168
Display the time-averaged wavelet spectrum of the signals as a waterfall plot.
waterfall(timeSpect) title("Time-Averaged Wavelet Spectrum") xlabel("Frequency Index") ylabel("Channel Index") zlabel("Power")

Display the instantaneous frequency of the signals as a waterfall plot.
waterfall(instFrq) view(30,40) title("Instantaneous Frequency") xlabel("Sample") ylabel("Channel Index") zlabel("Frequency")

Since R2025a
Extract time-domain, frequency-domain, and time-frequency features from healthy bearing vibration signals and faulty bearing vibration signals. While a healthy bearing vibration signal does not have outstanding defects, a faulty bearing vibration signal results from wear-and-tear defects, such as spalls on the gear teeth, eccentricity or gear misalignment, and cracks at the races.
For more information on bearing signal generation and analysis, see Vibration Analysis of Rotating Machinery. To learn more about the feature extraction and model training workflow to identify faulty bearing signals in mechanical systems, see Machine Learning and Deep Learning Classification Using Signal Feature Extraction Objects.
Generate Healthy Bearing Signal
Generate a healthy bearing vibration signal as a sum of three cosine pulses with amplitudes of 0.4 V, 0.2 V, and 1 V, respectively, and frequencies of 22.5 Hz, 8.36 Hz, and 292.5 Hz, respectively, for three seconds and with a sample rate of 20 kHz. Generate Gaussian noise and add it to the signal.
rng("default")
Fs = 20e3;
t = (0:1/Fs:3-1/Fs)';
a = [0.4 0.2 1];
f = [22.5 8.36 292.5];
sClean = cos(2*pi*f.*t)*a';
sHealthy = sClean + 0.2*randn(size(t));Generate Faulty Bearing Signal
Generate a faulty bearing vibration signal by adding a bearing impact signal to the healthy bearing signal. Model each impact as a 3 kHz sinusoid windowed by a Kaiser window. The defect causes a series of 10-millisecond impacts on the bearing.
tImpact = t(t<10e-3)'; xImpact = sin(2*pi*3000*tImpact).*kaiser(length(tImpact),40)'; xImpactBper = 0.33*pulstran(t,0:1/104.5:t(end),xImpact,Fs);
Generate a faulty bearing vibration signal using the healthy bearing signal and the bearing impact signal.
sFaulty = sHealthy + xImpactBper;
Consolidate and Visualize Signals
Bundle the healthy bearing and faulty bearing signals in a signalDatastore object in single precision.
sds = signalDatastore({sHealthy,sFaulty},OutputDataType="single");Plot the power spectrum of the healthy and faulty vibration signals. Observe the peaks that correspond to the bearing impact.
[P,F] = pspectrum([sHealthy sFaulty],Fs); p = plot(F/1000,pow2db(P)); p(1).Marker = "."; xlabel("Frequency (kHz)") ylabel("Power Spectrum (dB)") legend(["Healthy" "Faulty"])

Set Up Feature Extraction Pipeline
Create a signalTimeFeatureExtractor object for time-domain feature extraction.
timeFE = signalTimeFeatureExtractor(SampleRate=Fs,...
RMS=true,ImpulseFactor=true,StandardDeviation=true);Create a signalFrequencyFeatureExtractor object for frequency-domain feature extraction.
freqFE = signalFrequencyFeatureExtractor(SampleRate=Fs, ...
MedianFrequency=true,BandPower=true,PeakAmplitude=true);Create a signalTimeFrequencyFeatureExtractor object to extract time-frequency features from a spectrogram. Set the leakage parameter for the spectrogram to 90%.
timeFreqFE = signalTimeFrequencyFeatureExtractor(SampleRate=Fs, ... SpectralKurtosis=true,SpectralSkewness=true,TFRidges=true); setExtractorParameters(timeFreqFE,"spectrogram",Leakage=0.9);
Extract Multidomain Features
Extract signal features using all three feature extractors for the signals in the signalDatastore object sds. Concatenate the multidomain features. Display the first four columns in a feature table.
featureCell = cellfun(@(a,b,c) [real(a) real(b) real(c)], ... extract(timeFE,sds),extract(freqFE,sds),extract(timeFreqFE,sds), ... UniformOutput=false); featureMatrix = cell2mat(featureCell); featureTable = array2table(featureMatrix); head(featureTable(:,1:4))
featureMatrix1 featureMatrix2 featureMatrix3 featureMatrix4
______________ ______________ ______________ ______________
0.80115 0.80116 3.2635 292.39
0.80538 0.80539 3.1501 292.41
More About
The signalTimeFrequencyFeatureExtractor object sets up a signal framing and feature extraction
pipeline to extract time-frequency features.
To customize the feature extraction pipeline based on your selected features, specify
properties when you
create the signalTimeFrequencyFeatureExtractor object. For example, set up a feature extraction
pipeline that extracts these features:
Short-time Fourier transform (STFT) features: Spectral crest and time-frequency ridges
Fourier synchrosqueezed transform (FSST) features: Spectral entropy
Variational mode decomposition (VMD) features: Instantaneous frequency
Include scalar features for the spectral entropy and time-frequency ridges.
tfOpts = timeFrequencyFeatureTransformOptions( ... SpectralCrest="spectrogram",TFRidges="spectrogram", ... SpectralEntropy="synchrosqueezedspectrogram", ... InstantaneousFrequency="vmd"); sFE = signalTimeFrequencyFeatureExtractor( ... Transform=tfOpts, ... SpectralCrest=true,TFRidges=true, ... SpectralEntropy=true, ... InstantaneousFrequency=true) setScalarizationMethods(sFE,"SpectralEntropy",Energy=true,PeakValue=true) setScalarizationMethods(sFE,"TFRidges",Mean=true)
sFE =
signalTimeFrequencyFeatureExtractor with properties:
Properties
FrameSize: []
FrameRate: []
SampleRate: []
IncompleteFrameRule: "drop"
FeatureFormat: "matrix"
Transform: [1×1 timeFrequencyFeatureTransformOptions]
ScalarizationMethod: [1×1 timeFrequencyScalarFeatureOptions]
Enabled Features
SpectralCrest, SpectralEntropy, TFRidges, InstantaneousFrequency
Disabled Features
SpectralKurtosis, SpectralSkewness, SpectralFlatness, InstantaneousBandwidth, MeanEnvelopeEnergy, InstantaneousEnergy
WaveletEntropy, TimeSpectrum, ScaleSpectrumTip
To extract features from a signal, use the
extractfunction. When you use theextractfunction, the function executes the pipeline and returns the features in a matrix, table, or cell array, depending on the value specified inFeatureFormat.To set parameters of a time-frequency feature for feature extraction, use the
setExtractorParametersfunction. For example, this code sets parameters for theTFRidgesfeature for asignalTimeFrequencyFeatureExtractorobjectsFE.setExtractorParameters(sFE,"TFRidges",NumRidges=3,Penalty=2)
The Transform
property of a signalTimeFrequencyFeatureExtractor object specifies the analysis methods used
to represent an input signal in the time-frequency domain for features extraction. To set
the Transform property, use a timeFrequencyFeatureTransformOptions object or a struct array.
Each one of these values corresponds to a time-frequency analysis method:
"spectrogram"— Short-time Fourier transform"synchrosqueezedspectrogram"— Fourier synchrosqueezed transform"synchrosqueezedscalogram"— Wavelet synchrosqueezed transform"emd"— Empirical mode decomposition"vmd"— Variational mode decomposition"wavelet"— Maximal overlap discrete wavelet transform"waveletpacket"— Maximal overlap discrete wavelet packet transform"scalogram"— Continuous wavelet transform magnitude
To learn more about time-frequency analysis methods, see Time-Frequency Gallery.
Tip
Before extracting features, you can set parameters for a time-frequency analysis
method. For more information, see setExtractorParameters. For example, this code sets parameters for the
"spectrogram" analysis method for a
signalTimeFrequencyFeatureExtractor object
sFE.
setExtractorParameters(sFE,"spectrogram",Leakage=0.9,OverlapPercent=80)To set the methods for extracting scalar values from feature vectors in the time-frequency
domain, set the scalarization method property of a signalTimeFrequencyFeatureExtractor object with a timeFrequencyScalarFeatureOptions object. All time-frequency features support
scalarization.
For a given feature vector v with N elements, the scalarization method options convert v to a scalar s as follows.
"Mean"— Mean, defined as the average value of v."StandardDeviation"— Standard deviation of the elements of v, normalized by N-1."PeakValue"— Peak value, defined as the maximum absolute value of v."Kurtosis"— Kurtosis, defined as the ratio between the fourth moment of v and the squared second moment of v."Skewness"— Skewness, defined as the ratio between the third moment of v and the second moment of v raised to the power of 1.5.
"ClearanceFactor"— Clearance factor, defined as the ratio between the peak value of v and the squared mean of the square roots of the absolute values of v."CrestFactor"— Crest factor, defined as the ratio between the peak value of v and the root-mean-square value of v."ImpulseFactor"— Impulse factor, defined as the ratio between the peak value of v and the average absolute value of v."Energy"— Energy, defined as the sum of the squared values of v."Entropy"— Entropy, defined as the sum of plog2p values, where p is the vector of normalized squared values of v with respect to their sum.where
Note
The WaveletEntropy and SpectralEntropy features
do not support the "Entropy" scalarization method.
Algorithms
Assume that you are extracting time-frequency features from an input signal
x sampled at a rate Fs. When you specify signal
framing properties (FrameSize,
FrameRate or
FrameOverlapLength, and IncompleteFrameRule), the feature extractor sets up the signal partitioning
operation for x to extract features for each frame.
This table shows the equivalent syntaxes that signalTimeFrequencyFeatureExtractor uses to
partition the signal x into frames of size fl, frame
rate fr or frame overlap length ol, and incomplete frame
rule ifr. If you do not specify signal framing properties,
signalTimeFrequencyFeatureExtractor considers x as a single-framed
signal.
| Frame Specifications | Feature Extractor Object Specification | Signal Framing Operation Equivalency |
|---|---|---|
sFE = signalTimeFrequencyFeatureExtractor( ... FrameSize=fl,FrameRate=fr, ... IncompleteFrameRule=ifr); |
xFrames = framesig(x,fl, ... OverlapLength=fl-fr, ... IncompleteFrameRule=ifr); | |
sFE = signalTimeFrequencyFeatureExtractor( ... FrameSize=fl,FrameOverlapLength=ol, ... IncompleteFrameRule=ifr); |
xFrames = framesig(x,fl, ... OverlapLength=ol, ... IncompleteFrameRule=ifr); |
These sections list the features that a signalTimeFrequencyFeatureExtractor object supports for
each time-frequency analysis method and compares the syntax equivalency with individual
feature extractor functions.
Note
To obtain the equivalent syntax for the feature extraction setup based on the
properties specified when you create the signalTimeFrequencyFeatureExtractor object, use
generateMATLABFunction.
This code defines the short-time Fourier transform ("spectrogram") as
the analysis method to represent the input signal in the time-frequency
domain.
s = "spectrogram"; tfSTFT = timeFrequencyFeatureTransformOptions(SpectralKurtosis=s,SpectralSkewness=s,SpectralCrest=s, ... SpectralFlatness=s,SpectralEntropy=s,TFRidges=s,InstantaneousBandwidth=s,InstantaneousFrequency=s);
x and the sample rate
Fs, this table lists the equivalent syntaxes for extracting features
using the signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tfSTFT, ... SpectralKurtosis=true, ... SpectralSkewness=true, ... SpectralCrest=true, ... SpectralFlatness=true, ... SpectralEntropy=true, ... TFRidges=true, ... InstantaneousBandwidth=true, ... InstantaneousFrequency=true); features = extract(sFE,x); |
[S,F,T] = pspectrum( ... x,Fs,"spectrogram"); features = [ ... spectralKurtosis(S,F)' ... spectralSkewness(S,F)' ... spectralCrest(S,F)' ... spectralFlatness(S,F)' ... spectralEntropy(S,F)' ... tfridge(S,F)' ... instbw(S,F,T)' ... instfreq(S,F,T)' ... ]; |
This code defines the Fourier synchrosqueezed transform
("synchrosqueezedspectrogram") as the analysis method to represent the
input signal in the time-frequency
domain.
s = "synchrosqueezedspectrogram"; tfFSST = timeFrequencyFeatureTransformOptions(SpectralKurtosis=s,SpectralSkewness=s,SpectralCrest=s, ... SpectralFlatness=s,SpectralEntropy=s,TFRidges=s,InstantaneousBandwidth=s,InstantaneousFrequency=s);
x and the sample rate
Fs, this table lists the equivalent syntaxes for extracting features
using the signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tfFSST, ... SpectralKurtosis=true, ... SpectralSkewness=true, ... SpectralCrest=true, ... SpectralFlatness=true, ... SpectralEntropy=true, ... TFRidges=true, ... InstantaneousBandwidth=true, ... InstantaneousFrequency=true); features = extract(sFE,x); |
[S,F,T] = fsst(x,Fs); S = abs(S).^2; F = F/(2*pi); features = [ ... spectralKurtosis(S,F)' ... spectralSkewness(S,F)' ... spectralCrest(S,F)' ... spectralFlatness(S,F)' ... spectralEntropy(S,F)' ... tfridge(S,F)' ... instbw(S,F,T)' ... instfreq(S,F,T)' ... ]; |
This code defines the wavelet synchrosqueezed transform
("synchrosqueezedscalogram") as the analysis method to represent the
input signal in the time-frequency
domain.
s = "synchrosqueezedscalogram"; tfWSST = timeFrequencyFeatureTransformOptions(SpectralKurtosis=s,SpectralSkewness=s,SpectralCrest=s, ... SpectralFlatness=s,SpectralEntropy=s,TFRidges=s,InstantaneousBandwidth=s,InstantaneousFrequency=s);
x and the sample rate
Fs, this table lists the equivalent syntaxes for extracting features
using the signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tfWSST, ... SpectralKurtosis=true, ... SpectralSkewness=true, ... SpectralCrest=true, ... SpectralFlatness=true, ... SpectralEntropy=true, ... TFRidges=true, ... InstantaneousBandwidth=true, ... InstantaneousFrequency=true); features = extract(sFE,x); |
[S,F] = wsst(x,Fs); S = abs(S).^2; T = (0:1:size(S,2)-1)/Fs; features = [ ... spectralKurtosis(S,F)' ... spectralSkewness(S,F)' ... spectralCrest(S,F)' ... spectralFlatness(S,F)' ... spectralEntropy(S,F)' ... tfridge(S,F)' ... instbw(S,F,T)' ... instfreq(S,F,T)' ... ]; |
This code defines the empirical mode decomposition ("emd") as the
analysis method to represent the input signal in the time-frequency
domain.
tfEMD = timeFrequencyFeatureTransformOptions( ... InstantaneousFrequency="emd",MeanEnvelopeEnergy="emd",InstantaneousEnergy="emd");
x and the sample rate Fs,
this table lists the equivalent syntaxes for extracting features using the
signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tfEMD, ... InstantaneousFrequency=true, ... MeanEnvelopeEnergy=true, ... InstantaneousEnergy=true); features = extract(sFE,x); |
[imf,~,d] = emd(x,MaxNumIMF=10); [~,~,~,F,E] = hht(imf,Fs); m = d.MeanEnvelopeEnergy'; features = [ ... F(:)' ... m zeros(1,10-numel(m)) ... E(:)' ... ]; |
This code defines the variational mode decomposition ("vmd") as the
analysis method to represent the input signal in the time-frequency
domain.
tfVMD = timeFrequencyFeatureTransformOptions(InstantaneousFrequency="vmd",InstantaneousEnergy="vmd");
x and the sample rate Fs,
this table lists the equivalent syntaxes for extracting features using the
signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs,Transform=tfVMD, ... InstantaneousFrequency=true, ... InstantaneousEnergy=true); features = extract(sFE,x); |
[~,~,~,F,E] = hht(vmd(x),Fs); features = [ ... F(:)' ... E(:)' ... ]; |
This code defines the maximal overlap discrete wavelet transform
("wavelet") as the analysis method to represent the input signal in the
time-frequency
domain.
tfMODWT = timeFrequencyFeatureTransformOptions(WaveletEntropy="wavelet", ... InstantaneousFrequency="wavelet",InstantaneousEnergy="wavelet");
x and the sample rate
Fs, this table lists the equivalent syntaxes for extracting features
using the signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tfMODWT, ... InstantaneousFrequency=true, ... InstantaneousEnergy=true, ... WaveletEntropy=true); features = extract(sFE,x); |
mra = modwtmra(modwt(x)); imf = permute(mra,[2 1 3]); [~,~,~,F,E] = hht(imf,Fs); features = [ ... F(:)' ... E(:)' ... wentropy(modwt(x))' ... ]; |
This code defines the maximal overlap discrete wavelet packet transform
("waveletpacket") as the analysis method to represent the input signal
in the time-frequency
domain.
tfMODWPT = timeFrequencyFeatureTransformOptions(WaveletEntropy="waveletpacket", ... InstantaneousFrequency="waveletpacket",InstantaneousEnergy="waveletpacket");
x and the sample rate
Fs, this table lists the equivalent syntaxes for extracting features
using the signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tfWODWPT, ... InstantaneousFrequency=true, ... InstantaneousEnergy=true, ... WaveletEntropy=true); features = extract(sFE,x); |
d = modwptdetails(x); imf = permute(d,[2 1 3]); [~,~,~,F,E] = hht(imf,Fs); features = [ ... F(:)' ... E(:)' ... wentropy(modwpt(x))' ... ]; |
This code defines the continuous wavelet transform magnitude
("scalogram") as the analysis method to represent the input signal in
the time-frequency
domain.
tfCWT = timeFrequencyFeatureTransformOptions(TimeSpectrum="cwt",ScaleSpectrum="cwt");
x and the sample rate
Fs, this table lists the equivalent syntaxes for extracting features
using the signalTimeFrequencyFeatureExtractor object and the individual feature extractor
functions.
| Features | Feature Extractor Object | Individual Feature Extractors |
|---|---|---|
|
sFE = signalTimeFrequencyFeatureExtractor( ... SampleRate=Fs, ... Transform=tfCWT, ... TimeSpectrum=true, ... ScaleSpectrum=true); features = extract(sFE,x); |
fb = cwtfilterbank( ... SignalLength=numel(x)); features = [ ... timeSpectrum(fb,wt(fb,x))' ... scaleSpectrum(fb,wt(fb,x)) ... ]; |
References
[1] Moody, G.B., and R.G. Mark. “The Impact of the MIT-BIH Arrhythmia Database.” IEEE Engineering in Medicine and Biology Magazine 20, no. 3 (June 2001): 45–50. https://doi.org/10.1109/51.932724.
Extended Capabilities
Usage notes and limitations:
You cannot generate code directly from
signalTimeFrequencyFeatureExtractor. You can generate C/C++ code from the function returned bygenerateMATLABFunction.
Refer to the usage notes and limitations in the C/C++ Code Generation section. The same usage notes and limitations apply to GPU code generation.
Usage notes and limitations:
To extract features in parallel using a
signalTimeFrequencyFeatureExtractorobject, use theextractfunction with theUseParalleloption set totrue. You must have a Parallel Computing Toolbox™ license to use this functionality.
For more information about parallel support with MATLAB®, see Run MATLAB Functions with Automatic Parallel Support (Parallel Computing Toolbox).
Usage notes and limitations:
To extract features from GPU array input using a
signalTimeFrequencyFeatureExtractorobject, use theextractfunction.Extracting features from the
"emd"and"vmd"transforms of GPU array input is not supported.The
InstantaneousEnergyproperty is supported only if you specifyTransformas"wavelet"or"waveletpacket".
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2024aThe Transform property of signalTimeFrequencyFeatureExtractor objects will
no longer support string scalars or character vectors in a future release. Instead, specify
Transform as a timeFrequencyFeatureTransformOptions
object or a struct array.
If you create or edit a signalTimeFrequencyFeatureExtractor object whose
Transform property is specified as a string scalar or character
vector, signalTimeFrequencyFeatureExtractor automatically sets Transform to a
timeFrequencyFeatureTransformOptions object.
The signalTimeFrequencyFeatureExtractor object supports gpuArray objects.
You must have Parallel Computing Toolbox to use this functionality.
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)