The frequency axis for the PSD of a signal
조회 수: 7 (최근 30일)
이전 댓글 표시
Suppose I have the signal x that contains N samples, and I take the FFT of this signal and rearrange the frequency components to have the 0 frequency componenet to the center
X = fftshift(fft(x));
and then calculate the PSD of the signal as
psd = (1/(fs*N))*abs(X).^2;
where fs is the sampling frequency, what is the exact frequency axis that corresponds to psd in this case? If I defined it as
freq = -fs/2:fs/N:fs/2;
it would be 1 element greater than the size of psd, but if I define it as
freq = -fs/2+fs/N:fs/N:fs/2;
it will be of the same size as psd.
Is the second definition accurate? If yes, why the negative frequencies don't extend to -fs/2 as it's the case for the positive frequencies?
댓글 수: 0
답변 (1개)
Abhaya
2024년 10월 11일
Hi Mawe,
I understand you want to find the frequency axis for the Power Spectral Density (PSD) of a signal, spanning from ‘-fs/2’ to ‘fs/2’.
The following line of the given code returns ‘N+1’ points, which includes both the endpoints.
freq = -fs/2:fs/N:fs/2
Also, the second definition in the code provides ‘N’ points but does not maintain zero symmetry.
freq = -fs/2+fs/N:fs/N:fs/2
To achieve all frequency bins symmetrically around zero, you can use the code given below:
freq = -fs/2 : fs/N : fs/2 - fs/N;
If you want to include both the endpoints in frequency vector, you can use ‘linspace’ function of MATLAB.
freq= linspace(-fs/2,fs/2,N);
For better understanding, please follow the MATLAB documentations given below.
Hope this solves your query.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!