Getting wrong results with fft
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!!
0 commentaires
Réponses (1)
Paul
le 16 Fév 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)|')
0 commentaires
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!