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/method-selection-guide.md
Time-Frequency Method Selection Guide
Diagnostic Workflow
When a user asks for time-frequency analysis without specifying a method, examine the signal and recommend the best approach.
Step 1: Gather signal properties
fs = ...; % sample rate (ask user if not provided)
Nx = length(x);
duration = Nx / fs;
% Quick spectral overview
[pxx, f] = pwelch(x, [], [], [], fs);
% Transient indicators
K = kurtosis(x); % K >> 3 suggests impulsive/transient content
% Bandwidth estimate (3 dB bandwidth around peak)
[~, ipk] = max(pxx);
fpeak = f(ipk);
pxx_norm = pxx / max(pxx);
bw3dB = f(find(pxx_norm > 0.5, 1, 'last')) - f(find(pxx_norm > 0.5, 1, 'first'));
fractionalBW = bw3dB / fpeak; % > 1 = broadband, < 0.1 = narrowbandStep 2: Classify and recommend
| Signal characteristic | Indicator | Recommended method |
|---|---|---|
| Sharp transients at multiple scales (ECG QRS, impacts, clicks) | Kurtosis >> 3, short-duration bursts | CWT (cwt) |
| Closely-spaced tones at HIGH frequencies | Δf/fc < 1/Q (CWT can't resolve) | STFT (spectrogram or stft) |
| Slowly varying frequency content, stationary-ish | Low kurtosis, spectral content stable over time | STFT (spectrogram or stft) |
| Need to modify spectrum and reconstruct | User says "filter", "remove", "denoise" in frequency domain | stft/istft |
| Closely-spaced narrowband tones (same octave band) | Multiple peaks within a 2:1 frequency ratio | modwptdetails or vmd |
| Well-separated frequency bands (different octaves) | Peaks in different octave bands | modwt + modwtmra |
| Non-linear oscillatory modes, AM/FM | Amplitude or frequency modulation visible | EMD (if few modes) or VMD (if count known) |
| Log-frequency analysis (music, audio) | Musical pitch tracking, harmonic structure | cqt/icqt |
| Need sharp instantaneous frequency tracks | Chirps, frequency sweeps | fsst (STFT-based) or wsst (wavelet-based) |
| High time-frequency resolution (research) | Need Wigner-Ville without cross-terms | wvd (single component) or wsst (multi-component) |
| Additive decomposition into frequency bands | User wants "components that sum to original" | modwtmra or modwptdetails |
Step 3: Validate the recommendation
After choosing a method, run a quick sanity check:
% For CWT recommendation — verify it reveals structure STFT misses
figure
tiledlayout(2,1)
nexttile
cwt(x, fs)
title("CWT (scalogram)")
nexttile
pspectrum(x, fs, "spectrogram")
title("Spectrogram")Show both to the user and explain why one is better for their signal.
Decision Tree (quick reference)
Does the user need to modify and reconstruct the signal?
├── YES → stft/istft (check length condition and COLA)
└── NO
├── Does the signal have sharp transients or multi-scale structure?
│ ├── YES → CWT (cwt)
│ └── NO
│ ├── Are there closely-spaced frequency components?
│ │ ├── YES, known count → VMD
│ │ ├── YES, want uniform bands → modwptdetails
│ │ └── NO
│ │ ├── Want additive time-domain components?
│ │ │ ├── Components in different octaves → modwt + modwtmra
│ │ │ └── Components in same octave → modwptdetails
│ │ └── Want time-frequency display?
│ │ ├── Need sharp IF tracks → fsst or wsst
│ │ ├── Log-frequency (music) → cqt
│ │ └── General purpose → spectrogram
└── SPECIAL CASES
├── Complex-valued signal → modwt/modwtmra or modwptdetails (not EMD/VMD)
├── Only have STFT magnitude → stftmag2sig
└── ML feature extraction → modwt or modwtLayer (deterministic, fixed structure)Example: Why CWT for ECG
load wecg.mat
fs = 180;ECG signals have:
Sharp QRS complexes (5–25 Hz energy, ~100 ms duration) — need fine time resolution
Slow P and T waves (0.5–5 Hz) — need fine frequency resolution
Multi-scale structure — different clinically relevant features at different scales
CWT provides fine time resolution at high frequencies (resolves QRS timing) AND fine frequency resolution at low frequencies (separates P/T waves) simultaneously. STFT with a fixed window forces a single time-frequency tradeoff — a window short enough to resolve QRS timing gives poor frequency resolution for the slow waves.
% CWT reveals multi-scale ECG structure
figure
cwt(wecg, fs)
% Compare: spectrogram struggles with the tradeoff
figure
pspectrum(wecg, fs, "spectrogram")Example: Why STFT for closely-spaced high-frequency tones
CWT has constant-Q: bandwidth = center_frequency / Q. At high frequencies, this means wide bandwidth — poor frequency resolution. STFT has constant bandwidth (fs/M) at all frequencies.
% DTMF example: tones at 3600 and 3700 Hz (100 Hz apart), fs = 8000 Hz
% STFT resolution: 8000/256 = 31.25 Hz — easily resolves both tones
% CWT at 3650 Hz (Q~20 for bump wavelet): bandwidth ~182 Hz — CANNOT resolve them
% STFT wins for closely-spaced high-frequency components
[S,F,T] = stft(x, fs, Window=hamming(256), OverlapLength=250, FrequencyRange="onesided");Rule of thumb: If the tone separation Δf is small relative to the center frequency (i.e., Δf/fc < 1/Q), CWT cannot resolve the components. Use STFT instead.
Note: Synchrosqueezing (wsst) can sharpen CWT frequency localization and partially overcome this limitation — covered in the synchrosqueezing reference.
Example: Why STFT for steady-state vibration
A machine vibration signal with constant-speed rotation has:
Stationary harmonic content (shaft frequency + harmonics)
No rapid transients during normal operation
Need to track amplitude of specific harmonics over time
STFT is ideal: fixed frequency resolution tuned to the harmonic spacing, uniform time grid for trending.
% For harmonics spaced 25 Hz apart at fs = 10000:
M = ceil(2 * fs / 25); % ~800 samples for Hann window
spectrogram(x, hann(M), round(0.75*M), 2*M, fs, 'yaxis')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 or 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