fft of given data

조회 수: 4 (최근 30일)
Juan
Juan 2013년 11월 16일
댓글: Wayne King 2013년 11월 17일
I got data from a lab, and the FFT I get have a peak in zero Hz. But it is not right, it should have a peak at 50 Hz (european frecuncy). I just don't know what else to try, I'm without new ideas of way to continuo. Please give me an adavise!
The data is xlsx below.
Summering:
% same as in http://www.mathworks.es/es/help/matlab/ref/fft.html but with Fs=150, thus 150/2=75 so close to my 50 Hz, and y and t are vectors given.
y=v;
Fs = 150; % Sampling frequency
% T = 1/Fs; % Sample time
L = length(t); % Length of signal
% t = (0:L-1)*T; % Time vector
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(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
  댓글 수: 2
Juan
Juan 2013년 11월 17일
Finally semi solved, from
x=i;
%//If youre getting a massive peak at zero that dwarfs everything else, you
%//probably have a large DC offset. Easily removed in the time domain using
%//the following ..
x = x-mean(x);
tAxis = t;
dt = diff(tAxis(1:2)); %//sample period from time axis
fs = 1/dt;%//sample rate from sample period
NFFT = numel(x); %//number of fft bins - change if you like
Y = abs(fft(x, NFFT)).^2; %power spectrum
%//Calculate frequency axis
df = fs/NFFT;
fAxis = 0:df:(fs-df);
%//Plot it all
figure; plot(fAxis(1:NFFT/2), Y(1:NFFT/2))
xlabel('Frequency in Hz')
ylabel('Power')
xlim([0,300]);
Juan
Juan 2013년 11월 17일
Note: for better view of my data
change:
NFFT = 1e6;
add:
xlim([0,300]);
PD: it seems like i didnt need help from here, the stackoverflow-given-an-array-of-data-extract-possible-frequencies-with-fft-how-to would have been enough, but I wont delete this. This may help others.

댓글을 달려면 로그인하십시오.

답변 (1개)

Wayne King
Wayne King 2013년 11월 16일
편집: Wayne King 2013년 11월 16일
That indicates that the data has a non-zero mean. First, subtract the mean
y = detrend(y,0);
or simply
y = y-mean(y);
Then execute your commands above.
  댓글 수: 2
Juan
Juan 2013년 11월 17일
편집: Juan 2013년 11월 17일
Thanks for the answer.
But that doesnt solve the problem. The DC offset or mean is so small that I think is not a problem:
>> mean(y)
ans =
1.3573e-13
>> max(y)
ans =
309.9389
Wayne King
Wayne King 2013년 11월 17일
which column in the excel file is the data you are trying to Fourier transform? what is the title of the column

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by