Spectrogram with log scale
30 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Star Strider
on 12 Aug 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 Comments
Star Strider
on 13 Aug 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')
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!