FFT function in matlab
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens

if true
% close all;clear all;clc
load('short_6washer')
t = data(:,1);
Amp = data(:,2);
Fs = 1/(t(2) - t(1)); % Sampling frequency
L = length(data(:,1)); % Length of signal
f = Fs*(0:(L/2))/L;
figure subplot(2,1,1) plot(t,Amp) xlabel('t (seconds)') ylabel('X(t) [V]') Y = abs(fft(Amp)); % f = (0:length(Y)-1)*10000/length(Y); P = 2*abs(Y(1:length(f)))/L; subplot(2,1,2) plot(f,P) axis([-5 15 0 6]) xlabel('f (Hz)') ylabel('amplitude [V]')% end
I am doing the FFT of the attached file in matlab. The image is what I got but it seems wrong to me. If it is wrong, can someone debug the code for me? The sample frequency is 10000Hz and the data was collected in 10 seconds.
2 commentaires
Joost Meulenbeld
le 12 Mar 2018
Modifié(e) : Joost Meulenbeld
le 12 Mar 2018
With no attached code, it's hard to debug your code; what exactly seems wrong to you? How did you compute the real one-sided fourier spectrum?
Réponses (1)
David Goodmanson
le 12 Mar 2018
Modifié(e) : David Goodmanson
le 12 Mar 2018
Hi siyu,
Things are actually working correctly, and the only real problem is that your wave is oscillating about the value 2.5. That means that there is a large DC component of that size. (It also means that if you are going to be doubling the size of Y array elements, you should not double the size of the first array element. That element corresponds to frequency = 0, i.e. DC. That peak was the correct size, 2.5, before it got doubled).
Assuming you are not particularly interested in the DC component, then you will get better results by taking it out, with
Y = abs(fft(Amp-mean(Amp)));
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!