Spectrogram with log scale
30 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Star Strider
2015-8-12
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 个评论
Star Strider
2015-8-13
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')
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
