spectrogram plotting of Amplitude frequency vs. frame

Hi,
I used spectrogram matlab function in order to obtain a STFT as follows:
nfft=1024;
noverlap=nfft/2;
wnd= hamming(nfft,'periodic');
[Y, F, T, P] = spectrogram (y, wnd, noverlap, nfft, fs);
Now, I am trying to plot a 3D plot of frequency , amplitude for each frame I have. can anyone help please.
Thanks in advance

 Réponse acceptée

From the documentation for spectrogram:
spectrogram(...) plots the PSD estimate for each segment on a surface in a figure window. The plot is created using
surf(T,F,10*log10(abs(P)));
axis tight;
view(0,90);
So to get your 3D plot, simply comment out (or remove) the view(0,90) call, or change it to a different azimuth and elevation.

6 commentaires

Mona
Mona le 14 Déc 2014
Great! this works, but the problem is that the color comes in black. Besides is there a way to plot sections of the array, i.e. half of F and T and P because the plot seem too busy
It may be coming out black because of the number of points in your fft evaluation. See if reducing it to 512 or even lower makes the plot more readable. Everything else in your code scales with ‘nfft’, so no other changes should be necessary.
Mona
Mona le 14 Déc 2014
I tried going as low as 128 fft points, but still it was too busy. I also tried the following: T2 = T(1:64,1:10); F2 = F(1:64,1:10); P2 = P(1:64,1:10);
surf(T2,F2,10*log10(abs(P2))); axis tight;
But I got an error. The idea, I just want to see sections of it.
Another option is to substitute mesh for surf.
Mona
Mona le 14 Déc 2014
Great!!!!! mesh worked much better than surf.... Thanks alot
My pleasure!
I use mesh frequently when surf is too dense.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by