필터 지우기
필터 지우기

Using fft() to calculate PSD.

조회 수: 1 (최근 30일)
2one
2one 2012년 6월 21일
I used the code below perform spectral analysis of signal with known period of 4 s:
load lujan.dat
data_out.time = lujan(:,1);
data_out.disp = lujan(:,2);
Y = fft(data_out.disp,1000);
Y(1)=[];
NY = length(Y);
Pyy = abs(Y(1:floor(NY/2))).^2;
nyquist = 1/2;
f = (1:NY/2)/(NY/2)*nyquist;
plot(f,Pyy,'-b','LineWidth',3);
title('Power spectral density');
xlabel('Frequency (Hz)');
However the output graph shows a peak at 0.05 Hz which is not correct! IS there something obvious i'm doing wrong?
thanks

채택된 답변

Wayne King
Wayne King 2012년 6월 21일
Are you sure the sampling frequency is 1 ? If so, how far off is the peak from where you expect it to be? Is it almost correct or way off? You also don't tell us how long the time series is, so we don't know why you are adding the length input argument to fft() . Your frequency increment of 1/NY (0.0025) is correct.
  댓글 수: 1
2one
2one 2012년 6월 21일
the signal is from 0 to 12 sec, sampled every 0.2 sec (61 points total).
the signal has period of 4 s so frequency peak should be at 0.25 hZ but graph is showing peak at 0.05 Hz (which would mean 20 s period).

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

추가 답변 (1개)

Wayne King
Wayne King 2012년 6월 21일
Then your sampling frequency is specified incorrectly.
Fs = 1/0.2;
% here I'll create a signal just to show you
t = 0:1/Fs:12-1/Fs;
x = cos(2*pi*0.25*t)+randn(size(t));
Y = fft(x,256);
Pyy = abs(Y(1:floor(256/2)+1)).^2;
freq = 0:Fs/256:5/2;
plot(freq,10*log10(Pyy))
grid on
set(gca,'xtick',[0 0.25 0.5 1 1.5 2 2.5])

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by