FFT function in matlab
조회 수: 12 (최근 30일)
이전 댓글 표시

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
Joost Meulenbeld
2018년 3월 12일
편집: Joost Meulenbeld
2018년 3월 12일
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?
답변 (1개)
David Goodmanson
2018년 3월 12일
편집: David Goodmanson
2018년 3월 12일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!