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:
[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!