필터 지우기
필터 지우기

Change ylim of spectogram

조회 수: 2 (최근 30일)
Dominik Deml
Dominik Deml 2023년 6월 10일
댓글: Simon Chan 2023년 6월 10일
I'd like to change the `ylim` (frequency) values of my spectogram plot.
fs = 20000;
n = 0:5*fs - 1;
N = length(n);
t = n/fs;
fT = 1000;
fM = 3;
delta_phiT = 10;
uFM = 1*cos(2*pi*fT*t + delta_phiT*sin(2*pi*fM*t));
spectrogram(uFM, 1024, 256, 4096, fs, 'yaxis');
What I tried so far:
ylim([800 1200]);
But after doing this the spectogram is empty.

채택된 답변

Simon Chan
Simon Chan 2023년 6월 10일
편집: Simon Chan 2023년 6월 10일
It should divide by 1000.
fs = 20000;
n = 0:5*fs - 1;
N = length(n);
t = n/fs;
fT = 1000;
fM = 3;
delta_phiT = 10;
uFM = 1*cos(2*pi*fT*t + delta_phiT*sin(2*pi*fM*t));
spectrogram(uFM, 1024, 256, 4096, fs, 'yaxis');
ylim([800 1200]/1000); % Divide by 1000
  댓글 수: 2
Dominik Deml
Dominik Deml 2023년 6월 10일
Thank you! Can you explain me why?
Simon Chan
Simon Chan 2023년 6월 10일
Here is the original code:
fs = 20000;
n = 0:5*fs - 1;
N = length(n);
t = n/fs;
fT = 1000;
fM = 3;
delta_phiT = 10;
uFM = 1*cos(2*pi*fT*t + delta_phiT*sin(2*pi*fM*t));
spectrogram(uFM, 1024, 256, 4096, fs, 'yaxis');
After that, you can extract the axis information as follows and it shows that the y-limit is from -0.0024 to 10.0024, but not something from -0.0024 to 10,002.4.
On the other hand, the ylabel in the above figure shows that the unit is in kHz instead of Hz and hence you need to divide the freqency in Hz by 1000 in this case.
ax=gca
ax =
Axes with properties: XLim: [0.0064 4.9600] YLim: [-0.0024 10.0024] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1164 0.1100 0.6937 0.8150] Units: 'normalized' Show all properties

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by