Borrar filtros
Borrar filtros

How can i get desired frequencies appearing in graph ,from variables, created by spectrogram function?

1 visualización (últimos 30 días)
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 comentarios
Abhishek Maurya
Abhishek Maurya el 14 de Mzo. de 2018
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.
Abhishek Maurya
Abhishek Maurya el 15 de Mzo. de 2018
I also checked 17th row of wW variable, which is frequency but it is not giving accurate answer, it gave 156250, which is close to 160 kHz but if using graph(zoomming it) then its giving exactly 160 KHz at centre of bright yellow line. There is clearly visible that 156250 is not centre of yellow line if used 'grid on'.

Iniciar sesión para comentar.

Respuesta aceptada

David Goodmanson
David Goodmanson el 16 de Mzo. de 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.

Más respuestas (0)

Categorías

Más información sobre Time-Frequency Analysis 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