Don't forget to zoom on the brightest yellow line seen in 2nd column until you get 160 kHz on y-axis exactly at midth of yellow line.
How can i get desired frequencies appearing in graph ,from variables, created by spectrogram function?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abhishek Maurya
le 14 Mar 2018
Commenté : Abhishek Maurya
le 16 Mar 2018
See: FOrQuestioning.m file in Attachment. As it can be seen in 2nd column out of 10 columns i have created in graph,there is a dominant frequency of 160kHz.
I want 160kHz to be extracted from variables that i created.
So first i found the max spectral density in second column which was 17th row. Thus coordinates (17,2). By using: [~,MaxpPsIndex]=max(pPs(:,2))
Now when i look for (17,2) in sS variable.By using: abs(sS(17,2)).i didn't got 16kHz.
2 commentaires
Réponse acceptée
David Goodmanson
le 16 Mar 2018
Hi Abhishek
It appears that you have the impression that the fourier spectrum of a snippet of a cosine (or sine) wave at frequency f0 should peak out exactly at frequency f0. That is not the case. The 160kHz wave you are looking at lasts for about 7.5 cycles. Here is an example for 7.5 cycles of a 1 Hz wave, and to avoid questions about what an fft might be doing, it plots the exact analytic solution in the frequency domain. The peak is slightly above 1 Hz.
b = 7.5;
f0 = 1
f = .5:.0001:1.5;
g1 = (exp(2*pi*i*( f0-f)*b)-1)./(i*( f0-f));
g2 = (exp(2*pi*i*(-f0-f)*b)-1)./(i*(-f0-f));
g = (1/2)*(g1+g2); % frequency domain function
figure(1)
plot(f,abs(g))
figure(2) % closeup
plot(f,abs(g))
xlim([.99 1.01])
On the spectrogram plot in your code, if you zoom in on the yellow band you can see it is shifted slightly above 160kHz, consistent with the 1Hz result. If you put the following plot at the end of your code
figure(5)
plot(wW,abs(sS(:,2)))
xlim([1e5 2.2e5])
it shows that that while the highest value is less than 160kHz due to luck, the peak actually is going to fall at a value slightly greater than 160kHz, consistent with the spectrogram display.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Time-Frequency Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!