How do I interpret output data from spectrogram function

8 visualizaciones (últimos 30 días)
Ryan Troha
Ryan Troha el 2 de Jun. de 2021
Respondida: Sudarsanan A K el 29 de Abr. de 2024
I have a dataset of 57794048 samples with a sampling rate of 32000 Hz. I would like to extract power data at each sample point using the spectrogram function. I've tried using the code below with X being the dataset. I end up with s being 8388609 x 1 complex double, t being 1 x 8 double, and f being 8388609 x 1 double. Can someone help me interpret this output? Why am I only getting 8 timepoints?
fs = 32000;
[s,f,t] = spectrogram(X,[],[],[],fs);

Respuestas (1)

Sudarsanan A K
Sudarsanan A K el 29 de Abr. de 2024
Hello Ryan,
The output you are observing from the "spectrogram" function is as expected due to how the function processes the input signal:
  • "s" (STFT Matrix): The complex matrix "s" represents the power spectral density of each signal segment. Its size is influenced by the FFT length, and the parameters specified in the "spectrogram" function call.
  • "t" (Time Vector): The 1 x 8 dimension for "t" indicates that the spectrogram computed the signal's power spectral density at 8 distinct time points. This is a direct result of how the input signal is divided into overlapping segments by the function, with the exact number of time points depending on the signal's length and the specified parameters.
  • "f" (Frequency Vector): This vector lists the frequencies at which the spectrogram was computed, with its size determined by the FFT length and the parameters used in the function.
If your aim is to extract power data for each sample point across the entire frequency spectrum without segmenting the signal, the "periodogram" function is more suitable for your needs. Unlike the "spectrogram", which analyzes the signal in segments, the "periodogram" computes the Power Spectral Density (PSD) for the entire signal:
fs = 32000;
[P,f] = periodogram(X, [], [], fs);
Here, "P" gives the power spectral density at each frequency "f", providing a comprehensive view of the signal's power distribution across frequencies without dividing it into segments.
You can also use "pwelch" function for estimating the power spectral density of a signal, which provides more control over the window function, overlap, and other parameters compared to the "periodogram" function. It also automatically handles the windowing and averaging of the segments, making it a convenient choice for power spectral density estimation. Please refer to the respective documentations given below for further details:
I hope this helps!

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by