Ali
Ali

Reputation: 91

FFT faulty results for high frequencies?

I have sampled the 50Hz output current of an inverter with sampling frequency of 50 KHz for 1 minute. I am supposed to divide the time to 200ms packages(0.2s or 10 periods of the main signal)and do the FFT on each package. So it means that I have 10000 samples in each package (if not I zero pad or truncate ,that does not make a big difference). I am also supposed to extract the frequency spectrum up to 9 KHz. Results are ok for low frequencies but I have wrong results (the values are the half of what for high frequency). Could you help me to understand what am I doing wrong?!

I have an idea, maybe some thing like the code below is happening to my FFT. Just change SF to 10000 and look how the results will be changed !

in this code if you change the SF(sampling frequency) from 30000 to 10000, 
the results for high frequncies will be distorted and disordered . why ?

SF = 30000; %sampling frequency

% signal 
t = 0:1/SF:1-1/SF; %  sample points
wave=15*sin(2*pi*1*t)+1*sin(2*pi*123*t)+2*sin(2*pi*203*t)+3*sin(2*pi*223*t)+4*sin(2*pi*331*t)+5*sin(2*pi*2812*t)+6*sin(2*pi*5752*t)+7*sin(2*pi*7993*t);


wavefft = fft(wave);

L=floor(size(wave,2)/2)+1; % removing the mirror side of spectrum
MagSpec = abs(wavefft(1:L))/(SF/2);  %% removing the mirror side of the spectrum 
and ranging the domain 

plot(MagSpec);

Upvotes: 3

Views: 461

Answers (1)

SleuthEye
SleuthEye

Reputation: 14579

What you are observing is aliasing.

As you can see by comparing the results using a sampling rate of 50kHz 50kHz sampling rate

and that of using a sampling rate of 10kHz 10kHz sampling rate

The sinusoidals signals whose frequency where below half the sampling rate of 10kHz (Nyquist frequency), that is the sinusoidals at 1Hz, 123Hz, 203Hz, 223Hz, 331Hz and 2812Hz are not affected. The ones at 5752Hz and 7993Hz are aliased to 4248Hz and 2007Hz respectively.

You can still perform the FFT on 200ms or 10000 samples, but the sampling rate remains the same at 50kHz. That is you would have:

SF = 50000; %sampling frequency

% signal 
t = 0:1/SF:1-1/SF; %  sample points
wave=15*sin(2*pi*1*t)+1*sin(2*pi*123*t)+2*sin(2*pi*203*t)+3*sin(2*pi*223*t)+4*sin(2*pi*331*t)+5*sin(2*pi*2812*t)+6*sin(2*pi*5752*t)+7*sin(2*pi*7993*t);

for the signal generation, but you would split the resulting wave signal in chunks for your processing:

for i=1:floor(length(wave)/10000)
  wavefft = fft(wave(1+(i-1)*10000:i*10000))
  % do somthing with the wavefft result
end

Upvotes: 4

Related Questions