Frequency resolution of Spectrogram
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a signal sampled on 50Hz, i want to do spectrogram analysis of this signal.

the command
spectrogram(x,'yaxis')
this is working fine But the problem is that my band of interest is between 0 to 2 Hz, how can i change the resolution of my spectrogram to see that band of interest.
And also i would like to change the Y axis scale from bins to Hz
댓글 수: 0
답변 (1개)
Aabha
2025년 5월 9일
편집: Aabha
2025년 5월 9일
The ‘spectogram’ function has a few optional arguments that can be used to modify the resolution of the spectogram. The argument ‘window’ refers to the size of the window and is specified as a positive integer or as a row or column vector. It is used to divide the signal into segments and affects the time-frequency resolution trade-off. The window size can be increased for better frequency resolution and decreased for better time resolution. Additionally, you can also specify the sample rate ‘fs’. It represents the number of samples per unit time. However, fs must be the fifth input to the ‘spectrogram’ function. To input a sample rate and still use the default values of the preceding optional arguments, specify these arguments as empty (‘[]’). Once you specify the sample rate, the units of the y-axis will automatically change to ‘Hz’ instead of ‘bins’.
Here is an example code for the same:
N = 1024;
n = 0:N-1;
w0 = 2*pi/5;
x = sin(w0*n)+10*sin(2*w0*n); % Example signal
Fs = 50; % Sample Rate
window = hamming(256); % Adjust window size for better resolution
noverlap = round(length(window)*0.75); % 75 percent overlap
nfft = 512; % Increase for better frequency resolution
spectrogram(x, window, noverlap, nfft, Fs, 'yaxis');
ylim([0 2]) % Set y-axis limit to 0-2 Hz
Please refer to the following MathWorks documentation link for more information about the 'spectogram' function:
I hope this helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
