Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to find frequency from image of spectrogram?

Asked by Sunil Shahi

Sunil Shahi (view profile)

on 30 Jun 2013

Here is what I have done so far.

[W,fs]=wavread(FileName); %this reads a wave file

[~,~,~,P]=spectrogram(W(:,end),tres,tres/2,fres,fs); %tres is time resolution %and fres is frequency resolution.

I=flipud(-log(P)); %here 'I' gives the spectrogram image in a matrix.

imshow(I,[]); %this line will display the image.

now my question is if I choose a pixel co-ordinate from the image matrix I how can I get its frequency?

0 Comments

Sunil  Shahi

Sunil Shahi (view profile)

1 Answer

Answer by Wayne King

Wayne King (view profile)

on 30 Jun 2013
Edited by Wayne King

Wayne King (view profile)

on 30 Jun 2013

If you output the vector of frequencies from spectrogram(), you will have the frequency information.

      t=0:0.001:2;                    
      x=chirp(t,0,1,150);             
      [y,f,t,p] = spectrogram(x,256,250,256,1000);

Each row of p corresponds to the frequency at the corresponding element of the vector, f. But keep in mind, that it's only as good as the frequency resolution you have. If you're looking for a technique that gives you instantaneous frequency and time behavior for a signal, it does not exist. You can only obtain information about a time-frequency rectangle of a minimum area.

0 Comments

Wayne King

Wayne King (view profile)

Contact us