Matlab Analyze Time Frequency Content
MathWorksOfficialCreated by MathWorks
- Skill
- Tool integration
- Science and research
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a comprehensive framework for analyzing how frequency content evolves over time using MATLAB. It covers a wide range of analytical techniques including Short-Time Fourier Transform (STFT), Continuous Wavelet Transform (CWT), synchrosqueezing, reassignment, and adaptive signal decomposition (EMD/VMD). The skill is designed to help users select the appropriate method based on their specific signal characteristics and research goals, offering guidance on visualization, mode extraction, and cross-signal analysis.
What it does
- Visualizes time-frequency content using spectrograms and scalograms.
- Supports advanced signal decomposition via EMD, VMD, and multiresolution analysis.
- Enables mode extraction and signal reconstruction from time-frequency representations.
- Computes time-varying coherence and cross-spectra between two signals.
- Provides diagnostic tools to assess signal properties before analysis.
- Offers a decision logic for choosing between STFT, CWT, and other transform methods.
When to use it
- When you need to analyze the evolution of frequency content over time.
- When choosing between different time-frequency representations like STFT or CWT.
- When you need to extract and reconstruct individual signal components.
- When comparing two signals using time-varying coherence or cross-spectrum analysis.
- When decomposing signals into additive time-domain components.
Advantages
- Provides a structured decision tree for selecting the optimal analysis method.
- Includes diagnostic scripts to assess signal length, bandwidth, and nonstationarity.
- Supports both interactive exploration and programmatic data analysis.
- Clearly distinguishes between invertible and non-invertible analysis techniques.
- Offers specific guidance on handling boundary effects and frequency resolution.
Usage examples
- “How do I visualize the time-frequency content of a non-stationary signal?”
- The agent will recommend using signalAnalyzer for interactive exploration or cwt for multi-resolution visualization, depending on the signal's bandwidth.
- “I need to extract a specific mode from my signal using synchrosqueezing.”
- The agent will guide you through the fsst or wsst workflow, including ridge extraction and subsequent signal reconstruction.
- “How can I compare the time-varying coherence of two signals?”
- The agent will provide the wcoherence syntax and explain how to interpret the phase arrows and coherence magnitude.
- “What is the best way to decompose a signal into adaptive components?”
- The agent will recommend emd or vmd based on whether the number of components is known and provide the necessary function calls.
Install
1 of its files are not mirrored here, so install it from its source:
https://github.com/matlab/matlab-agentic-toolkit/tree/2a7f215e965597acf6ed495beb9e7b8aff45a3be/skills-catalog/signal-processing/matlab-analyze-time-frequency-content
Documentation by MathWorks
Time-Frequency Analysis in MATLAB
Analyze how frequency content evolves over time using STFT, CWT, synchrosqueezing, reassignment, cross-signal methods, and data-adaptive decomposition.
Agent directive: Consult the reference guides in
references/before answering. Each guide covers a specific domain with syntax, gotchas, and common mistakes.
When To Use
Analyzing how frequency content evolves over time (spectrogram, scalogram)
Choosing between STFT, CWT, synchrosqueezing, reassignment, or EMD/VMD
Extracting and reconstructing individual signal components from a TF representation
Computing time-varying coherence or cross-spectrum between two signals
Decomposing signals into additive time-domain components (wavelet MRA, EMD, VMD)
Estimating instantaneous frequency or Hilbert spectrum
When Not To Use
Designing or applying classical FIR/IIR filters — use
matlab-design-digital-filterExtracting scalar features for ML classification — use
matlab-extract-signal-featuresSignal preprocessing (resampling, detrending, gap filling) — use
matlab-prepare-signal-dataQuadratic/bilinear TFDs (Wigner-Ville) — not supported in MATLAB toolboxes
Audio-specific representations (mel spectrogram, MFCC) — use Audio Toolbox
Method Selection
Choose the analysis method based on the user's goal and signal characteristics:
| Goal | Method | Guide |
|---|---|---|
| Interactive TF exploration (spectrogram + scalogram) | signalAnalyzer | — |
| General TF visualization (uniform freq resolution) | stft, spectrogram, pspectrum | references/stft-guide.md |
| TF visualization (multi-resolution, constant-Q) | cwt, cwtfilterbank | references/cwt-guide.md |
| Sharpest TF picture (non-invertible) | spectrogram("reassigned"), pspectrum(Reassigned=true) | references/reassignment-guide.md |
| Remove specific TF regions (mask-based filtering) | tffilt with binary mask | references/stft-guide.md |
| Mode extraction + reconstruction (STFT domain) | fsst → tfridge → ifsst | references/reassignment-guide.md |
| Mode extraction + reconstruction (CWT domain) | wsst → wsstridge → iwsst | references/reassignment-guide.md |
| Signal reconstruction from CWT | icwt (exact or approximate) | references/cwt-guide.md |
| Additive decomposition (octave bands) | modwt + modwtmra | references/multiresolution-guide.md |
| Additive decomposition (uniform bands) | modwptdetails | references/multiresolution-guide.md |
| Adaptive decomposition (unknown components) | emd | references/multiresolution-guide.md |
| Adaptive decomposition (known mode count) | vmd | references/multiresolution-guide.md |
| Hilbert spectrum / instantaneous frequency | hht, instfreq | references/multiresolution-guide.md |
| Time-varying coherence between two signals | wcoherence | references/cross-analysis-guide.md |
| Cross spectrogram between two signals | xspectrogram | references/cross-analysis-guide.md |
| Global coherence (no time axis) | mscohere, cpsd | references/cross-analysis-guide.md |
For detailed decision logic, see references/method-selection-guide.md.
Quick Decision Tree
What is the primary goal?
│
├── Interactive exploration (adjust parameters, compare views)
│ └── signalAnalyzer — supports spectrogram + scalogram (CWT) side by side
│
├── Visualize one signal's TF content
│ ├── Need uniform frequency resolution? → stft / spectrogram / pspectrum
│ ├── Need multi-resolution (better low-freq)? → cwt
│ └── Need sharpest picture (no reconstruction)? → spectrogram("reassigned")
│
├── Remove unwanted content visible in spectrogram
│ └── Define binary mask over TF plane → tffilt (Gabor domain)
│
├── Extract and reconstruct individual components
│ ├── From TF representation (invertible)?
│ │ ├── STFT domain → fsst → tfridge → ifsst
│ │ └── CWT domain → wsst → wsstridge → iwsst
│ ├── Additive time-domain components?
│ │ ├── Octave bands → modwt + modwtmra
│ │ ├── Uniform bands → modwptdetails
│ │ └── Data-adaptive → emd or vmd
│ └── From CWT directly? → icwt (see references/cwt-guide.md)
│
├── Compare two signals
│ ├── Time-varying coherence? → wcoherence
│ ├── Time-varying cross-spectrum? → xspectrogram
│ └── Global relationship? → mscohere / cpsd
│
└── Estimate instantaneous frequency
├── Single monocomponent signal? → instfreq(x, fs)
├── Multicomponent (want per-mode IF)? → emd → instfreq(imf, fs)
└── Multicomponent (want single average)? → instfreq(x, fs, Method="tfmoment")Critical Rules
stfthas no reassignment option. Usefsstfor invertible synchrosqueezing orspectrogram("reassigned")for non-invertible visualization.wsstridgeargument order differs fromtfridge:wsstridge(sst, penalty, f, ...)— penalty is 2nd positional argtfridge(tfm, f, penalty, ...)— penalty is 3rd positional arg
wsstsubtracts the signal mean internally.iwsstdoes NOT restore it. Addmean(x)back manually if DC matters.ifsstis machine-precision;iwsstis approximate (Morlet single-integral formula).xspectrogramfirst output is real (cross-spectrogram magnitude). For phase, use the 4th outputP. This differs fromspectrogramwhose first output is complex STFT.wcoherencehas noParentoption. For App Designer, compute outputs and plot manually.wcoherencephase arrows show the phase lag of Y relative to X:↑ = Y lags X by π/2
↓ = Y leads X by π/2
→ = in-phase
← = anti-phase
PhaseDisplayThreshold(default 0.5) is plot-only — it controls which arrows are drawn but has no effect on returned numeric outputs.
hhttakes IMFs, not raw signal. Always decompose first:imf = emd(x); hht(imf, fs).instfreqHilbert method is meaningless for multicomponent signals. Decompose first, or useMethod="tfmoment"for a single average curve.Synchrosqueezing is precision-sensitive. Use double-precision data with
fsst/wsstfor reproducible results across MATLAB, codegen, and GPU.
Signal Assessment Workflow
When the user provides a signal and asks "what should I use?", run the assessment script then apply agent-side interpretation:
Step 1: Run MATLAB assessment
report = assessSignalForTF(x, fs);
disp(report)
disp(report.recommendations)The script returns: signal length, occupied bandwidth, number of spectral peaks (with frequencies), nonstationarity indicator, DC content, precision, and auto-generated recommendations.
Step 2: Agent-side interpretation (combine script output with user goals)
| User Goal | Key Report Fields | Recommendation Logic |
|---|---|---|
| "Explore / I'm not sure what I need" | — | Suggest signalAnalyzer for interactive exploration (spectrogram + scalogram views, adjustable parameters) |
| "Visualize frequency content over time" | likelyNonstationary, fractionalBandwidth | If wideband (>2 octaves): cwt. If narrowband or uniform resolution needed: stft/spectrogram |
| "Separate/extract components" | numSpectralPeaks, peakFrequenciesHz | 2–3 peaks: synchrosqueezing (fsst/wsst). Many peaks: emd/vmd. Closely-spaced: modwptdetails or fsst |
| "Reconstruct after filtering" | hasDC, precision | fsst/ifsst for exact. wsst/iwsst for CWT-domain (warn about mean). icwt for CWT bandpass |
| "Compare two signals" | (run on both) | wcoherence for coherence. xspectrogram for cross-spectrum |
| "Detect transients/events" | signalLength, occupiedBandHz | cwt with low TimeBandwidth. Or short-window stft |
Step 3: Refine with follow-up questions if ambiguous
"Do you need to reconstruct the signal, or just visualize?"
"Do you need uniform frequency resolution, or is multi-resolution acceptable?"
"Are you comparing this signal to another?"
Reference Guides
| File | Coverage |
|---|---|
references/stft-guide.md | stft/istft, spectrogram, pspectrum, stftmag2sig, length preservation, COLA |
references/cwt-guide.md | cwt, cwtfilterbank, icwt, dlicwt/icwtLayer, boundary, constant-Q |
references/reassignment-guide.md | fsst/ifsst, wsst/iwsst, spectrogram("reassigned"), pspectrum(Reassigned=true), ridge extraction, penalty |
references/cross-analysis-guide.md | wcoherence, xspectrogram, cpsd, mscohere, phase arrows, unsmoothed cross-spectrum |
references/multiresolution-guide.md | modwt/modwtmra, modwpt/modwptdetails, emd, vmd, hht, instfreq, instbw |
references/method-selection-guide.md | Decision logic for choosing among all methods |
Toolbox Requirements
| Toolbox | Functions |
|---|---|
| Signal Processing | stft, istft, spectrogram, pspectrum, fsst, ifsst, tfridge, xspectrogram, instfreq, instbw, stftmag2sig, cpsd, mscohere |
| Wavelet | cwt, cwtfilterbank, icwt, wsst, iwsst, wsstridge, wcoherence, modwt, modwtmra, modwpt, modwptdetails, emd, vmd, hht, tffilt, dgt |
| Function | Available From | Note |
|---|---|---|
tffilt | R2025a | TF mask-based filtering; all other functions available in R2024b |
Documentation References
| Topic | Link |
|---|---|
| Time-frequency gallery | https://www.mathworks.com/help/signal/time-frequency-analysis.html |
| Wavelet time-frequency | https://www.mathworks.com/help/wavelet/time-frequency-analysis.html |
| CWT reference | https://www.mathworks.com/help/wavelet/ref/cwt.html |
| STFT reference | https://www.mathworks.com/help/signal/ref/stft.html |
| Synchrosqueezing example | https://www.mathworks.com/help/wavelet/ug/time-frequency-reassignment-and-mode-extraction-with-synchrosqueezing.html |
| Wavelet coherence example | https://www.mathworks.com/help/wavelet/ug/compare-time-frequency-content-in-signals-with-wavelet-coherence.html |
Copyright 2026 The MathWorks, Inc.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.1 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md10.7 KiB
- manifest.yaml517 B
- references/cross-analysis-guide.md11.7 KiB
- references/cwt-guide.md22.3 KiB
- references/method-selection-guide.md6.2 KiB
- references/multiresolution-guide.md17.9 KiB
- references/reassignment-guide.md11.8 KiB
- references/stft-guide.md16.4 KiB
- scripts/assessBoundary.m3.1 KiB
- scripts/assessSignalForTF.m4.8 KiB
- scripts/assessSpectralEnergy.m3.4 KiB
- scripts/boundaryExDisjointSine.mat(opens on GitHub)Not mirrored: opens on GitHub7.6 KiB
- scripts/illustrateBoundary.m902 B
- scripts/illustrateTransientLocalization.m1.3 KiB
- scripts/plotAntiAnalyticScalogram.m831 B
references/multiresolution-guide.md
Multiresolution Analysis in MATLAB
Decompose signals into additive time-domain components at different scales or equivalently different center frequencies using wavelet-based or data-adaptive methods.
Method Selection
| Signal characteristic | Method | Why |
|---|---|---|
| Broadband transients + slow trends | modwt + modwtmra | Dyadic (octave) bands; shift-invariant; perfect reconstruction |
| Closely-spaced tones at similar frequencies | modwptdetails or vmd | Uniform-bandwidth bands resolve components MODWT cannot separate. modwptdetails uses a fixed grid; vmd adapts band centers to the data (think of VMD as the data-adaptive analog of MODWPT) |
| Unknown number of components, exploratory | emd | Fully adaptive; no parameters needed |
| Known number of narrowband components | vmd | Optimization-based; specify exact mode count; robust to noise |
| ML feature extraction (fixed-structure required) | modwt + modwtmra or modwtLayer | Deterministic output topology; consistent feature dimensionality |
Deterministic Methods: MODWT and MODWPT
MODWT + MODWTMRA Pipeline
modwt computes wavelet coefficients. modwtmra converts them to additive time-domain components. These are sequential steps, not alternatives.
% Decompose into additive components
wt = modwt(x, "sym4", 6);
mra = modwtmra(wt, "sym4");
% Components sum to original (perfect reconstruction)
maxErr = max(abs(x - sum(mra, 1))); % ~1e-12
% Selective reconstruction: remove trend (approximation at last level)
detrended = x - mra(end, :);
% Keep only levels 3-5 (specific frequency band)
bandFiltered = sum(mra(3:5, :), 1);When to use modwt alone (without modwtmra):
Wavelet variance analysis:
modwtvarWavelet correlation by scale:
modwtcorr,modwtxcorrEnergy partitioning — the L2 norm of the coefficients equals the L2 norm of the signal
When to add modwtmra:
Need time-domain signal components (for plotting, listening, reconstruction)
Need to remove or keep specific frequency bands
Need components that sum pointwise back to the original
MODWPT and modwptdetails
modwptdetails computes uniform-bandwidth signal components directly. It takes the signal as input — it is NOT a post-processor for modwpt output.
% Uniform-bandwidth decomposition — takes signal directly
[details, packetlevs, cfreq] = modwptdetails(x, "sym4", 4);
% Components sum to original (perfect reconstruction)
maxErr = max(abs(x - sum(details, 1))); % ~1e-12
% Center frequencies in Hz (cfreq is normalized 0-0.5)
centerFreqsHz = cfreq * fs;When to use modwpt alone (without modwptdetails):
Energy or relative energy by frequency band —
modwptreturns these directly:
[wpt, packetlevs, cfreq, energy, relenergy] = modwpt(x, "fk18", 4);
% energy: energy of wavelet packet coefficients at each terminal node
% relenergy: fraction of total signal energy in each bandWavelet packet coefficients for classification or feature extraction
When to use modwptdetails:
Need time-domain signal components in uniform-width frequency bands
Need to separate closely-spaced components that fall in the same MODWT detail level
Choosing MODWT vs MODWPT
| Criterion | MODWT + MODWTMRA | modwptdetails |
|---|---|---|
| Frequency grid | Dyadic (octave): bandwidths double at each level | Uniform: all bands same width |
| Best for | Broadband signals, trends, multi-scale structure | Narrowband components at similar frequencies |
| Number of bands at level L | L details + 1 approximation | 2^L uniform bands |
| When MODWT fails | Two components in same octave band (e.g., 150 Hz and 200 Hz both in D2 at fs=1000) | — |
| When MODWPT is overkill | Signal has clear multi-scale structure (one component per octave) | — |
Frequency Band Computation
MODWT — dyadic bands:
Detail level j:
[fs/2^(j+1), fs/2^j]HzApproximation at level L:
[0, fs/2^(L+1)]Hz
MODWPT — uniform bands at terminal level L:
Bandwidth per band:
bw = (fs/2) / 2^LBand k (1-indexed):
[(k-1)*bw, k*bw]HzCenter frequency of band k:
(k - 0.5) * bwHz
modwpt and modwptdetails return rows in sequency order (monotonically increasing center frequency). Row 1 is the lowest frequency band, row 2^L is the highest. No reordering is needed — indexing by row directly corresponds to frequency.
These are approximate ideal passbands. Actual selectivity depends on the wavelet filter length.
Wavelet Selection and Frequency Selectivity
Longer wavelet filters produce sharper frequency bands (closer to ideal rectangular passbands) at the cost of worse time localization:
| Wavelet family | Filter length | Frequency selectivity | Time localization |
|---|---|---|---|
"haar" (db1) | 2 | Poor | Best |
"db4" | 8 | Moderate | Good |
"sym8" | 16 | Good | Moderate |
"fk18" | 18 | Excellent (optimized) | Moderate |
"fk22" | 22 | Excellent | Lower |
The Fejér-Korovkin (fk) family is specifically optimized for frequency concentration at a given filter length. "fk18" is the default for modwpt/modwptdetails.
Properties
| Property | MODWT/MODWPT coefficients | MODWTMRA/modwptdetails components |
|---|---|---|
| What it provides | L2 norm preservation (energy) | Perfect reconstruction (additivity) |
| Domain | Transform domain | Time domain |
| Use for | Variance/energy analysis by scale | Signal reconstruction, denoising, component visualization |
| Relationship | `sum( |
Input Support
| Capability | modwt / modwtmra | modwpt / modwptdetails | emd | vmd |
|---|---|---|---|---|
| Matrix (multichannel) | Yes — 3D output | No (software limitation) | No (fundamental — variable IMF count per channel) | No (fundamental — per-signal optimization) |
| Complex-valued signal | Yes | Yes | No (requires extrema — undefined for complex) | No (assumes analytic modes) |
| Complex wavelet filters | No (real orthogonal only; csym not yet supported) | No (same limitation) | N/A | N/A |
For complex-valued wavelet filters (csym family), use wavedec + wrcoef. This is the DWT path — it is NOT shift-invariant and has length constraints.
Energy Analysis with wavedec
wavedec provides L2-norm-preserving energy partitioning only when all three conditions are met:
Signal length is a power of 2
Orthogonal wavelet is used
dwtmode("per")(periodic extension)
If any condition is violated, energy partitioning is not exact. Prefer modwt for energy/variance analysis — it preserves the L2 norm unconditionally.
Data-Adaptive Methods: EMD and VMD
EMD (Empirical Mode Decomposition)
[imf, residual, info] = emd(x);
% imf: matrix where each column is an IMF (highest to lowest frequency)
% residual: monotonic remainder
% info: diagnostics (number of extrema, iterations per IMF)Key behavior: MaxNumIMF is an upper bound, not a target. The algorithm terminates when the residual has fewer than MaxNumExtrema extrema (default 1), regardless of MaxNumIMF.
% This may return fewer than 10 IMFs
[imf, residual] = emd(x, MaxNumIMF=10);
numReturned = size(imf, 2); % could be 5, 7, etc.VMD (Variational Mode Decomposition)
[imf, residual, info] = vmd(x, NumIMFs=3);
% Always returns exactly 3 modes
% info.CentralFrequencies: normalized center frequencies of each modeKey behavior: NumIMFs is an exact count. The optimization always returns this many modes. Central frequencies are in info.CentralFrequencies (normalized), NOT in the second output (which is the residual).
% Convert central frequencies to Hz (normalized cycles/sample * fs)
centralFreqsHz = info.CentralFrequencies * fs;PenaltyFactor (default 1000): controls mode bandwidth. Lower values allow wider bandwidth modes — useful for chirps or frequency-varying components.
EMD Decomposes into Modes, Not Frequencies
EMD extracts intrinsic mode functions (IMFs) — signals with well-defined instantaneous frequency — not sinusoidal components. An amplitude-modulated signal is already a valid IMF:
t = linspace(0, 1, 1000);
x = (1 + cos(2*pi*10*t)) .* cos(2*pi*100*t);
imf = emd(x);
size(imf, 2) % Returns 1 — EMD sees one modeThe STFT sees the same signal as three separate tones (90, 100, 110 Hz), but EMD correctly identifies the underlying modulated carrier as a single entity with time-varying envelope.
This means EMD is not interchangeable with MODWPT or VMD for separating closely-spaced tones. It operates on a fundamentally different notion of "component" — one defined by oscillatory structure and instantaneous frequency, not by Fourier frequency content.
Choosing EMD vs VMD
| Criterion | EMD | VMD |
|---|---|---|
| Parameters required | None | Must specify NumIMFs |
| Output count | Variable (signal-dependent) | Fixed (always NumIMFs modes) |
| What it separates | Modes (instantaneous frequency) | Narrowband components (Fourier frequency) |
| Mode mixing | Common (energy bleeds across IMFs) | Rare (optimization separates cleanly) |
| AM signals | Keeps as one mode (correct for IF analysis) | Splits into carrier +/- modulation tones |
| Chirp handling | Splits across IMFs | Can capture in one mode (reduce PenaltyFactor) |
| Mathematical basis | Iterative sifting (empirical) | Variational optimization (rigorous) |
| Use when | Exploratory; IF analysis; unknown modulated structure | Known number of narrowband components; need clean Fourier-sense separation |
Why Wavelet MRA is Preferred for Machine Learning
Deterministic methods produce the same decomposition structure for every signal:
Fixed number of bands at fixed frequencies → consistent feature dimensionality
Training and inference use the identical transform
Reproducible and parallelizable (no iterative convergence)
EMD produces different numbers of IMFs per signal — incompatible with fixed-shape feature matrices without padding/alignment. VMD has fixed count but mode frequency assignments vary across signals ("mode 2" means different bands for different inputs).
Deep learning entry points:
| Use case | Function | Notes |
|---|---|---|
| Network layer (standard architecture) | modwtLayer | Drop into dlnetwork; Algorithm="MODWTMRA" (default) or "MODWT"; calls dlmodwt under the hood |
| Custom training loop | dlmodwt | Accepts dlarray inputs; supports automatic differentiation; second output is the MRA |
% dlmodwt in a custom training loop — filters MUST be numeric vectors
% (not wavelet name) so gradient-descent updates to the filters persist
[Lo, Hi] = wfilters("sym4");
dlX = dlarray(reshape(x, 1, 1, []), "CBT"); % Channel-Batch-Time
[wt, mra] = dlmodwt(dlX, Lo, Hi, 4);
% Use mra directly as multi-channel features — no separate modwtmra call neededWhy filter vectors, not wavelet name: dlmodwt makes the filters optionally learnable via automatic differentiation. Passing a wavelet name string would re-read fixed coefficients each call, discarding any gradient updates. Always pass Lo/Hi vectors obtained from wfilters.
Hilbert-Huang Transform and Instantaneous Frequency
hht — Hilbert Spectrum
hht computes the Hilbert spectrum: a time-frequency representation built from the instantaneous frequency and energy of each IMF. Unlike STFT/CWT which spread energy across a kernel, the Hilbert spectrum places energy at a single frequency per IMF per time sample.
Input is IMFs, not the raw signal. The correct workflow:
imf = emd(x); % or vmd(x, NumIMFs=K)
[hs, f, t] = hht(imf, fs); % Hilbert spectrum (sparse matrix)Outputs (up to 5):
| Output | Content | Type |
|---|---|---|
hs | Hilbert spectrum — energy at each (freq, time) bin | Sparse matrix (nFreq × nTime) |
f | Frequency vector | Column vector |
t | Time vector | Column vector |
insf | Instantaneous frequency per IMF | nTime × nIMFs |
inse | Instantaneous energy per IMF | nTime × nIMFs |
Name-value options:
| Option | Default | Purpose |
|---|---|---|
FrequencyLimits | [0, fs/2] | Restrict frequency axis |
FrequencyResolution | (fmax-fmin)/100 | Bin width — default gives only 100 bins |
MinThreshold | -inf (dB) | Zero out low-energy bins (useful for clean display) |
Key points:
Zero-output call produces a plot
The sparse matrix
hsis the actual Hilbert spectrum — a legitimate TF representation, not just visualization dataDefault frequency resolution (100 bins) is coarse — increase with
FrequencyResolutionfor finer analysisMultiple IMFs contribute additively: if two IMFs have the same instantaneous frequency at time t, their energies accumulate in the same bin
Internally computes: analytic signal →
|z|²(energy),d/dt(unwrap(angle(z))) × fs/(2π)(frequency)
instfreq — Instantaneous Frequency Estimation
instfreq estimates instantaneous frequency of a signal. Two methods exist:
% Method 1: Hilbert (default) — requires monocomponent or pre-decomposed signal
[ifq, t] = instfreq(x, fs); % single signal via Hilbert
[ifq, t] = instfreq(imf, fs); % IMF matrix — one IF curve per column
% Method 2: TF-moment — works on raw multicomponent signals (centroid of spectrogram)
[ifq, t] = instfreq(x, fs, Method="tfmoment"); % first spectral moment of pspectrum
[ifq, t] = instfreq(P, F, T); % from pre-computed TFD (power, freq, time)Critical distinction:
Hilbert method:
fs/(2π) × diff(unwrap(angle(hilbert(x))))— physically meaningful only for narrowband/monocomponent signals. For multicomponent signals, decompose first withemd/vmd, then pass IMFs.TF-moment method: Weighted mean frequency from
pspectrumat each time step. Works on raw signals but gives only a single average frequency (not per-component).
Output is 1 sample shorter with Hilbert method (forward difference loses one sample).
instbw — Instantaneous Bandwidth
[ibw, t] = instbw(x, fs); % from signal (via pspectrum internally)
[ibw, t] = instbw(P, F, T); % from pre-computed TFD
[ibw, t] = instbw(x, fs, FrequencyLimits=[flo fhi]);Only uses the TF-moment method (2nd central spectral moment of
pspectrum) — no Hilbert optionMeasures spectral spread at each time instant
Useful for detecting transitions, broadband transients, or time-varying bandwidth
Workflow Summary
Raw signal
│
├── instfreq(x, fs, Method="tfmoment") → average IF (single curve)
├── instbw(x, fs) → spectral spread over time
│
└── emd(x) or vmd(x, NumIMFs=K)
│
├── instfreq(imf, fs) → per-IMF IF curves (Hilbert method)
└── hht(imf, fs) → Hilbert spectrum (full TF representation)Interactive Exploration
signalMultiresolutionAnalyzer — interactive app for comparing MRA methods side by side.
Supports: MODWT, EMD, VMD, EWT, TQWT
Does NOT support: MODWPT
Filters out complex-valued signals (only MODWT handles complex among app methods)
Recommend when: User is exploring which method works best for their signal
Use programmatic workflow when: Production code, batch processing, multichannel, complex-valued data, or need MODWPT
Common Mistakes
| Mistake | Why it's wrong | Correct approach |
|---|---|---|
Plotting modwt output as signal components | Coefficients are not time-domain components; they don't sum to the original | Use modwtmra to get additive components |
Using TimeAlign=true with modwtmra | Time-aligning circularly shifts coefficients for visual display; modwtmra needs unshifted coefficients for perfect reconstruction | Only use TimeAlign=true when visualizing coefficients directly; never before calling modwtmra |
Passing modwpt output to modwptdetails | modwptdetails takes the signal directly, not wavelet packet coefficients | Call modwptdetails(x, wname, level) |
| Using Butterworth filters when MODWT can't separate tones | Classical filters work but ignore the wavelet packet solution designed for this | Use modwptdetails for uniform-bandwidth separation |
Using "NumIMFs" with emd or "MaxNumIMF" with vmd | Parameter names are not interchangeable | emd: MaxNumIMF; vmd: NumIMFs |
Assuming EMD returns exactly MaxNumIMF modes | It's an upper bound; algorithm terminates on stopping criteria | Check size(imf, 2) after calling emd |
Using wavedec for energy analysis without checking conditions | Energy partitioning is only exact with power-of-2 length + orthogonal wavelet + periodic mode | Prefer modwt — L2 norm preservation is unconditional |
Recommending signalMultiresolutionAnalyzer for complex data | App filters out complex signals | Use modwt/modwtmra programmatically |
Passing raw signal to hht | hht expects IMFs (columns), not the raw signal — a single column gives meaningless single-mode spectrum | Decompose first: imf = emd(x); hht(imf, fs) |
Using instfreq (Hilbert) on multicomponent signals | Hilbert IF is only meaningful for narrowband/monocomponent signals | Decompose with emd/vmd first, or use Method="tfmoment" for a weighted average |
Expecting instfreq (Hilbert) output to be same length as input | Forward difference loses 1 sample | Output has N-1 samples |
Using default FrequencyResolution in hht for detailed analysis | Default is only 100 bins across [0, fs/2] — very coarse | Specify finer resolution: hht(imf, fs, FrequencyResolution=1) |
Copyright 2026 The MathWorks, Inc.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/signal-processing/matlab-analyze-time-frequency-content · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks.
Get it from the source
1 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: matlab/matlab-agentic-toolkit