Calculate spectrogram with logarithmic-spaced frequencies
22 次查看(过去 30 天)
显示 更早的评论
I'm trying to calculate a spectrogram where the frequencies are logarithmicaly spaced, instead of the usual linear.
I think my test script follows the documentation, but my two spectrograms are identical and are both clearly using linear frequency spacing.
Am I doing something wrong?
Attached is my test script and the data.
3 个评论
William Rose
2022-12-21
Your quesiton is clear. You have provided plots that show what is odd. You have provided your code and you have provided your data. The code shows the issue in question, and does not have a ot of extraneous things going on which distract from the quesiton at hand. It would be great if all quesitons on this site were as well posed as yours.
采纳的回答
更多回答(1 个)
William Rose
2022-12-21
@dormant, I agree that the bottom plot in your example, which should have the frequencies evenly spaced on a log scale, appears to have frequencies that are evenly spaced on a linear scale, contrary to what you expect and what you want. The help for spectrogram, for the "f" option, says "Cyclical frequencies, specified as a vector. f must have at least two elements, because otherwise the function interprets it as nfft. The units of f are specified by the sample rate, fs." I think this means f should be specified as frequencies normalized by fs. (Which is interesting, since Matlab's filtering routines normalize frequencies by the Nyquist frequency.) Your specification of f is not normalized by fs. Perhaps your f vector is ignored because the values are not all less than 1, which they should be, according to the help quoted above.
3 个评论
William Rose
2022-12-23
@dormant, Thank you for shairng your results. I'm glad you like the scalogram.
Even with the scalogram, the frequencies still appear to be linearly spaced, not log-spaced. I say this because the scalogram plot with a logarithmic frequency axis shows finer divisions at higher frequencies than at lower frequencies. In this respect the scalogram plot is not diferent than the spectrogram plots in your original post, which you did not like, due to the linear spacing of frequency samples.
I agree with you that the scalogram appears to have better resolution (better time-bandwidth product) than the spectrogram. I would have to compare spectrograms and scalograms of signals with simple, well defined time-varying frequency content, before having confidence in this conclusion. I am not fond of wavelets due to the difficulty in interpreting the results, and because the mother wavelet choice is somewhat arbitrary and will influence the results.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time-Frequency Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!