Filter löschen
Filter löschen

Getting wrong results with fft

6 Ansichten (letzte 30 Tage)
Kokalz
Kokalz am 16 Feb. 2014
Beantwortet: Paul am 16 Feb. 2014
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!!

Antworten (1)

Paul
Paul am 16 Feb. 2014
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)|')

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by