How can I change the scale of the Y-Axis Unit in a Spectrogram?

9 ビュー (過去 30 日間)
Berthold Daubner
Berthold Daubner 2015 年 8 月 20 日
回答済み: the cyclist 2015 年 8 月 20 日
This is my code: spectrogram(Data,window,[],Freqrange,Fs,'yaxis');
with Freqrange = 50:1000 and Fs = 12800
The problem is that the y-axis is drawn in kHz instead of Hz. How can I change the unit from kHz to Hz so that the Ticks are for example 50 instead of 0.05. Thanks for your help!

採用された回答

Star Strider
Star Strider 2015 年 8 月 20 日
I don’t have your data so I can’t run your code, but this idea should work:
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
yt = get(gca, 'YTick')
set(gca, 'YTick',yt, 'YTickLabel',yt*1E+4)
You might just need the last two lines (the ‘yt’ assignment and the set call). Experiment with that first, then a version of this entire code if that doesn’t work.

その他の回答 (1 件)

the cyclist
the cyclist 2015 年 8 月 20 日
You can manually set the tick locations and tick labels with commands like
set(gca,'XTick',[50 100 500 1000])
set(gca,'XTickLabel',[50 100 500 1000])

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by