Spectrogram with log scale

29 vues (au cours des 30 derniers jours)
Jinhyung Kim
Jinhyung Kim le 12 Août 2015
Commenté : Star Strider le 13 Août 2015
Recently, I'm trying to make a spectrogram image with log scale of Y-axis. Linear scale of spectrogram works well, but I'm in trouble with this log scale. I've checked so many answers of here and web pages as well, but every single tip was not helpful.
Here's my code for spectrogram with log scale.
------------------------------------------------------------------------------
[s,f,t,p] = spectrogram(raw,WINDOW,OVERLAP,N,Fs,'yaxis');
imagesc(t,f,10*log10(p), [1 100]);
set(gca,'YScale','log')
colormap(jet)
ylim([1, 1e2]);
axis xy
colorbar
---------------------------------------------------------------------------
When run this set of code, I can see that Y-axis is displayed in log scale, but nothing is displayed in spectrogram area. Only I can see is a white-blank space.
I can tell you guys; I really do all things that I got! But nothing solves my problem.
Even I tried "ax = gca; ax.YScale = 'log';" which is found in Matlab help, but it doesn't work.
Please someone help me!
Have a nice day. Thanks!

Réponses (1)

Star Strider
Star Strider le 12 Août 2015
The imagesc function may not be appropriate. Use surf instead:
t = 0:0.001:2;
x = chirp(t,100,1,200,'quadratic');
[s,f,t,p] = spectrogram(x,128,120,128,1e3);
figure(1)
surf(p)
view(0, 90)
axis tight
set(gca, 'YScale', 'log')
  2 commentaires
Jinhyung Kim
Jinhyung Kim le 13 Août 2015
I really appreciate you for your help, but It's not what I want. I tried this-surf-before making this question, but the results was not what I expected. When make a figure using this 'surf', black lines are displayed like grid. I tried to remove this grid like lines, but I can't. Besides, it makes power spectrum like a 80's-old-fashioned graphic. Like hercules graphic with dots and lines without anti-aliasing.
I'll attach a sample picture of spectrogram that has log scale. If you see my comment, please give me one more favor.
Above is a sample image of Y-axis in log scale.
Star Strider
Star Strider le 13 Août 2015
It is easy to turn off the grid lines:
t = 0:0.001:2;
x = chirp(t,100,1,200,'quadratic');
[s,f,t,p] = spectrogram(x,128,120,128,1e3);
figure(1)
sh = surf(p)
view(0, 90)
axis tight
set(gca, 'YScale', 'log')
set(sh, 'LineStyle','none')

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by