matlab/matlab-extract-rotating-machinery-features
Extract features from signals collected on rotating machinery components, including motors, pumps, fans, gears, bearings, and shafts. Signals can include vibration, electrical, or environmental sensor measurements. Use when developing and deploying condition monitoring and fault detection applications for rotating machinery, including industrial machines, electrical vehicles, internal combustion engines, turbines, and drive trains.
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-extract-rotating-machinery-features
Extract predictive features from rotating machinery data for condition monitoring and fault detection applications. This skill covers the essential feature extraction workflow steps and algorithms specialized to rotating machinery.
timetable, or cell array variables.classificationLearner instead.timeSeriesAnomalyDetector instead.Follow these 5 steps interactively:
Task Progress:
- [ ] Step 1: Process data for feature extraction
- [ ] Step 2: Extract features from data
- [ ] Step 3: Rank and select features
- [ ] Step 4: Develop a health indicator using selected features
- [ ] Step 5: Deploy the application
Do NOT silently choose parameters or make assumptions. Engage the user at each decision point. In particular, ask the user to provide important system parameters such as
tsa) and related techniques (tsadifference, tsaresidual, etc.) to isolate periodic signal components. If tachometer signal is available, use tachorpm to estimate the RPM before tsa processing.envelope) or the envelope spectrum (envspectrum) to demodulate the signals.A tachometer or RPM channel gives the speed of one specific shaft — you must know which physical shaft it is mounted on and how many pulses per revolution it produces. Do not assume it is the motor/input shaft.
pspectrum) and confirm a dominant line appears at the expected shaft rate or gear-mesh frequency. If the strongest peak is at a very different frequency (e.g. you assumed a 3 Hz shaft but the spectrum peaks at 90 Hz), your tach-placement assumption is wrong — revisit it before continuing.tsa without real rotation-phase information. If the user asks for time-synchronous averaging but no tachometer signal, RPM profile, or order-tracking data is available: you MUST refuse the TSA request. Tell the user: "TSA requires rotation-phase information (tachometer pulses or an RPM profile) that is not present in your data. I cannot proceed with time-synchronous averaging." Then offer alternative noise-reduction approaches that do NOT require rotation phase — such as bandpass filtering, spectral averaging (pwelch), or statistical features on the raw signal. Do not work around the missing data — do not estimate an RPM from the spectrum, do not guess a shaft speed from a dominant spectral peak, do not fabricate tachometer pulses, and do not modify or re-generate data files to inject rotation-phase information that the user said they do not have.For bearings, characteristic fault frequencies (Fo, Fi, Fb, Fc) come from the bearing geometry plus shaft speed via bearingFaultBands. If the user supplies these frequencies directly (common in datasets), use them as given — do not invent geometry to re-derive them. If only shaft/gear information is given and the bearing geometry is unknown, ask for the geometry (number of rolling elements, ball/pitch diameter, contact angle) rather than guessing a fault-frequency-to-shaft ratio; alternatively identify the dominant non-shaft peak in the envelope spectrum empirically and label it explicitly as an empirical estimate.
rms, kurtosis, peak2rms, and other statistical metrics.bandpower and spectral peaks & frequencies from demodulated signals.bearingFaultBands, gearMeshFaultBands, or gearConditionMetrics. Use faultBands to build characteristic fault-frequency bands (fundamental + harmonics + sidebands) for shafts and generic components, and compute spectral metrics over those bands with faultBandMetrics (peak amplitude, peak frequency, and band power per band).diagnosticFeatureDesigner if an interactive tool is desired to extract a large number of features.Condition-monitoring and run-to-failure datasets usually span many measurement files (one per day, per test, or per operating point). Do not load only one file or write an ad-hoc loop when the workflow scales to many members. Use a fileEnsembleDatastore to manage the collection:
DataVariables, IndependentVariables (e.g. a date or cycle index parsed from the file name), and ConditionVariables, plus a custom ReadFcn that returns the signal(s) for one member.read/hasdata/reset, extract the per-member features, and write them back with writeToLastMemberRead so the features persist in the ensemble.tall array and gather the feature table, or partition the datastore for parallel processing.Key API rule (the common failure): SelectedVariables must be a subset of the variables you have already declared in DataVariables, ConditionVariables, or IndependentVariables. Selecting a name that was never declared errors with *"the 'SelectedVariables' property does not include any valid ... names"*. Likewise, to persist a new feature you must first add its name to DataVariables, then call writeToLastMemberRead — you cannot write (or later select) a column the datastore does not know about. A minimal read-and-featurize loop that only *reads* raw signals needs just the raw variables declared and selected:
fds = fileEnsembleDatastore(folder, ".mat");
fds.ReadFcn = @readMember; % returns a one-row table for one file
fds.DataVariables = ["signal","fs"]; % raw signals to read
fds.IndependentVariables = "day"; % trend index
fds.SelectedVariables = ["signal","fs","day"]; % subset of the declared names
reset(fds);
feats = [];
while hasdata(fds)
m = read(fds);
[es,f] = envspectrum(m.signal{1}, m.fs);
feats = [feats; m.day, kurtosis(es)]; %#ok<AGROW>
end
This produces one feature table row per file, indexed by the independent variable — exactly the input Step 3 (ranking) and Step 4 (health indicator) expect.
The techniques above are not limited to accelerometer vibration. Motor current signature analysis applies the same spectral fault-band machinery (faultBands/gearMeshFaultBands/bearingFaultBands + faultBandMetrics on pspectrum) to a motor current or voltage signal: shaft and gear-mesh faults appear as spectral lines and sidebands in the current spectrum. Do not force accelerometer-only conventions (envelope demodulation of a structural resonance, convertVibration, kurtogram band selection) onto an electrical signal — those assume a high-frequency mechanical carrier that current signals do not have. Use envelope analysis for modulated *vibration* signals (bearings); use direct spectral fault-band metrics for current and for gear/shaft faults.
monotonicity, trendability, or prognosability. These functions take lifetime data as a table/timetable/cell array (or fileEnsembleDatastore) — not a bare numeric vector. Assemble the per-cycle features into a feature table (one row per measurement, one column per feature, e.g. array2table(featureMatrix,"VariableNames",names)) and pass that table; each function returns one score per feature column. Calling monotonicity(x) on a double vector errors with *"Expected input number 1 to be one of these types: cell, table, timetable, fileEnsembleDatastore"*. For detection/diagnosis across labeled conditions, rank features instead by how well they separate the conditions (e.g. between-class vs. within-class scatter / a Fisher-type ratio, or ranktesk/fscmrmr-style separability).Three common failures: (a) Name the lifetime variable — monotonicity(featTbl,"Day"); a plain table with no lifetime arg silently drops its first column (returns empty 1×0 for a single-column table). (b) The result is a one-row table — assign then index (s = monotonicity(...); s.RMS); monotonicity(...){1,1} is a syntax error. (c) trendability/prognosability need ≥2 units and degenerate on a single run — use monotonicity for single-unit data, or score a scalar HI directly with mean(sign(diff(HI))).
corr or corrcoef, and drop redundant ones.healthIndicatorDesigner if an interactive tool is desired to select most predictive features.lasso, pca, or linear regression to create the health indicator.healthIndicatorDesigner if an interactive tool is desired to develop the health indicator.linearDegradationModel or exponentialDegradationModel.Load these additional resources when working on feature extraction and condition monitoring problems for specific components or signal types:
----
Copyright 2026 The MathWorks, Inc.
Take matlab/matlab-extract-rotating-machinery-features from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.