Question about PSD calculation using FFT

조회 수: 3 (최근 30일)
Chris Hoer
Chris Hoer 2016년 6월 5일
댓글: Francesca 2022년 10월 18일
Hello everyone,
a short question about the calculation of the PSD using the FFT. I used the example code provided:
rng default
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t) + randn(size(t));
N = length(x);
xdft = fft(x);
xdft = xdft(1:N/2+1);
psdx = (1/(Fs*N)) * abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:Fs/length(x):Fs/2;
I understand each step except this one:
psdx(2:end-1) = 2*psdx(2:end-1);
Why do we double entry except the first and the last? Is it about the symmetry of the FFT?
Thanks ahead and best regards, Chris
  댓글 수: 1
Francesca
Francesca 2022년 10월 18일
Hi, i'm working on a similar work: can I ask you what this part means: PSDx = (1/(Fs*N)) * abs(DFTx).^2?

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

채택된 답변

Jeremy
Jeremy 2016년 6월 14일
The fft results in a spectra that includes positive and negative frequencies. Don't ask me to explain what a negative frequency really means but the negative frequency esults are just the conjugates of the positive frequency results. They are not needed for the PSD calculation which is why they are rmeoved by the following line:
xdft = xdft(1:N/2+1);
You have to account for the enrgy lost when this portion of the spectra is removed so we multiply the rest by 2. The 0Hz and Nyquist frequency results don't have an imaginary portion and are not included in the negative frequency portion so they are not muiltiplied by 2.
  댓글 수: 2
Chris Hoer
Chris Hoer 2016년 6월 14일
Hey Jeremy, I already thought, that it had something to do with the symmetric part. Thanks for making it clear!
harihara reddy
harihara reddy 2020년 4월 7일
how the negative frequency is removed by the above line

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by