How do I average fft results?

45 views (last 30 days)
Joshua Fuller
Joshua Fuller on 13 May 2011
Commented: Luis Enrique on 9 Jan 2014
Hello,
I've been staring at this problem for a few days now and I don't really understand why it is not producing a result that seems right.
I have split a long recorded data set (8192 data points) into smaller bits. Each section is the same length (512 data points) and starts when an external counter passed zero (approx 1 Hz), data was recorded at 260 Hz.
I have been finding the fft of each smaller data set and then finding the mean real and imaginary part, or magnitude and angle, and using the ifft function to recreate a signal. This is giving results that are 'low' compared to what I would expect given the signals that go into making the 'average' signal.
I don't understand why this is happening, can anyone help please?
I need to do my averaging in the frequency domain, rather than the time domain because, although the signal is highly periodic there were small cycle to cycle variations and the data sampling was via an external trigger. I need to be able to 'manually' average different spectral results because I will be using data from a number of different files, where each file is not a direct continuation of the previous one.
Am I even using the correct function? Or is there a much simpler way of doing this?
I hope this all makes sense. Thank you for your help.
Josh
  2 Comments
Jan
Jan on 13 May 2011
Please post the code you are using. If there is a bug, it is impossible to find it following your descriptions only.
Luis Enrique
Luis Enrique on 9 Jan 2014
I have the same problem Jan Simon. How did you solve this???

Sign in to comment.

Answers (1)

Jan
Jan on 13 May 2011
As far as I understand, you create the FFT and use only the mean frequency to recreate the signal? The I expect the recreated signal to be more silent, because you've damped most of the frequencies.
  1 Comment
Joshua Fuller
Joshua Fuller on 13 May 2011
Thanks for your reply.
This is an example of the code that I am using.
count1 = 0;
re_si_pxx(1:512,1:61) = 0; % the FFT signal needs to be manipulated in real and imaginary parts.
im_si_pxx(1:512,1:61) = 0;
for k = 1:r
if side_loc_to_use(k) + 511 < 8192;
gr = side_loc_to_use(k);
count1 = count1 + 1; % counter used to see how many times the if statement occurs
for g = 1:61
pxx(:,g) = fft(sidescp(gr:gr+511,g));
end
end
for ty = 1:61
% angle and magnitude method
re_si_pxx(:,ty) = re_si_pxx(:,ty) + abs(pxx(:,ty));
im_si_pxx(:,ty) = im_si_pxx(:,ty) + angle(pxx(:,ty));
end
end
re_si_pxx = re_si_pxx/(count1);
im_si_pxx = im_si_pxx/(count1);
%im_si_pxx = exp(1i*im_si_pxx);
recon = real(ifft(re_si_pxx(:,35).*exp(1i*im_si_pxx(:,35))))
% ive been testing this using data colomn number 35, but the problem exists on all the data sets
I hope that makes sense. The code 'runs' without a problem, but the output from the final line produces a data set with values below what would be expected from the data sxets that go in to make it.
This is not a problem about signal noise and I want to keep all the frequencies (that can be found from a 512 data point sample at 260Hz) within the results because in addition to the main frequency there may be other frequencies within the data and if there are I want to be able to find these.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!