필터 지우기
필터 지우기

Getting wrong results with fft

조회 수: 6 (최근 30일)
Kokalz
Kokalz 2014년 2월 16일
답변: Paul 2014년 2월 16일
Hi guys!
I just can't get my head around fft function in MATLAB. I have a set of variable-step data and variable-step time obtained from SIMULINK model. I now want to plot that data in frequency domain, but I just can't seem to get the right results. I used interp1 function to get fixed step size time and data. I then found sampling freq. as
fs = 1/(fixedTime(1)-fixedTime(2));
fq = fs/2; % Niquist freqency
But what do I do now, to find the frequency response of my data? just using abs(fft(data)) does not seem to do the job, as the results I get are different to what I would expect.
Thank you very much for your help!!

답변 (1개)

Paul
Paul 2014년 2월 16일
y = signal; %the signal you want to fft
L = length(y);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

카테고리

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