matlab-analyze-spectrum

Analyze signal spectra in MATLAB using nonparametric and parametric spectral estimators.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-analyze-spectrum
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-analyze-spectrum
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/signal-processing/matlab-analyze-spectrum
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-analyze-spectrum

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Choosing the right spectral estimator in MATLAB is error-prone: users confuse PSD with power spectrum, misuse manual FFT normalization, pick wrong windows, and get misleading peaks from noise or sidelobe masking. This Skill guides AI agents to select, compute, and verify spectral analyses correctly using Signal Processing Toolbox functions.

Core Features & Use Cases

  • Estimator Selection Guidance: Decision trees and preliminary data diagnostics (sampling type, signal length, spectral flatness, AR fitness) to choose between pspectrum, pwelch, periodogram, pmtm, pburg, pmusic, rootmusic, plomb, and poctave.
  • Spectral Measurements: Built-in functions for band power, occupied bandwidth, peak detection with noise-floor-relative thresholds, SNR, THD, SFDR, and spectral shape descriptors.
  • Streaming Spectral Analysis: Patterns for spectrumAnalyzer, dsp.SpectrumEstimator, and dsp.CrossSpectrumEstimator for frame-by-frame real-time processing.
  • Use Case: A user provides a vibration signal and asks for its frequency content. The Skill runs preliminary diagnostics, recommends pwelch for the wideband signal, computes the PSD with proper windowing, detects peaks above the noise floor, and verifies results with Parseval's theorem.

Quick Start

Ask the agent to analyze the frequency content of your signal, for example: compute the power spectral density of my signal x sampled at 1000 Hz and find the dominant spectral peaks.

Frequently Asked Questions about matlab-analyze-spectrum

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compute a power spectral density in MATLAB?

Use pwelch for long signals where segment averaging reduces variance, or periodogram for short signals that cannot be segmented. For a quick look with automatic defaults, use pspectrum(x,Fs). Always pass the sample rate Fs explicitly and use pow2db for dB display.

What is the difference between PSD and power spectrum in MATLAB?

PSD measures power per Hz and is resolution-independent, making it suitable for noise characterization and comparing signals. Power spectrum measures power per bin so peak height equals true tone power, making it better for reading tone amplitudes. Convert between them using the resolution bandwidth RBW = enbw(win)*Fs/segLen.

pwelch vs pspectrum vs periodogram: which should I use?

Use pspectrum for quick exploration with good defaults and a Leakage parameter. Use pwelch for low-variance PSD estimates on long signals. Use periodogram for short signals or when you need exact Fs/N resolution and explicit window control. Use pmtm for short data needing low variance without segmentation.

Why do I see only one peak when my signal has two tones?

Either the tones are closer than the frequency resolution Fs/N, or sidelobes from the stronger tone mask the weaker one. Fix resolution by acquiring more data or using rootmusic for super-resolution; fix masking by switching to a lower-sidelobe window such as blackmanharris or kaiser with high beta.

Can I analyze non-uniformly sampled signals in MATLAB?

Yes. For nearly uniform data with small timing jitter, pspectrum(x,t) resamples internally. For truly non-uniform or gapped data, use plomb(x,t), which computes the Lomb-Scargle periodogram and supports detection-probability thresholds via the Pd option.

When should I not use this spectral analysis approach?

Do not use it for filter design, time-frequency or spectrogram analysis such as STFT and CWT, audio-specific features like MFCC or pitch, or control system frequency response such as Bode plots. Those tasks belong to dedicated toolboxes and workflows.