Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
when to correct for energy and amplitude in windowed signal spectrum?

Subject: when to correct for energy and amplitude in windowed signal spectrum?

From: shinchan Tung

Date: 8 Oct, 2010 23:44:04

Message: 1 of 4

When should I multiply the correction factor to a windowed signal? Before FFT or after? I thought I read it somewhere that ECF is multiplied to the spectrum *AFTER* you do FFT, so I use following code to test how cosistent the estimates of sum of square are in time domain and frequency domain. The code below shows that multiply ECF before FFT is a better estimate than after FFT. I just want to get a confirmation from you experts. Also, is subtracting the mean necessary before FFT?
Thanks for your help.


t=0:1:279; %test for discontinuity and spectrak leakage.
Fo = 0.01;
Fs = 1;

timeseries=cos(2*pi*Fo*t);
timeseries=timeseries';
fprintf('Nonwindowed sum of square in time domain = %g. \n', sum(timeseries.^2));
n=length(timeseries);
sampling_frequency = Fs;

f = sampling_frequency*(0:ceil(n/2))/n; %f is fraction of sampling freq.
f = f';
Ftimeseries = fft(timeseries);
power = Ftimeseries.*conj(Ftimeseries)/n;
power_h = 2*power(1:ceil(n/2)+1); % power is symmetric, so multiply the positive frequency side by 2.

fprintf('Nonwindowed sum of square in frequency domain = %g. \n', sum(timeseries.^2));

%multiply timeseries by a Hanning window before FFT.
windowHanning = window(@hann, n);
windowedSignal = windowHanning.*timeseries;
windowedSignal = windowedSignal - mean(windowedSignal);
fprintf('Windowed sum of square in time domain = %g. \n', sum(windowedSignal.^2));
FwindowedSignal = fft(windowedSignal);
power = FwindowedSignal.*conj(FwindowedSignal)/n;
power_h = 2*power(1:ceil(n/2)+1);
fprintf('Windowed sum of square in frequency domain = %g. \n', sum(power_h));

%multiply windowed signal by energy correction factor 2/sqrt(1.5) before
%FFT

windowedSignal = windowedSignal * 2/sqrt(1.5);
windowedSignal = windowedSignal - mean(windowedSignal);
fprintf('Windowed, energy corrected sum of square in time domain = %g. \n', sum(windowedSignal.^2));
FwindowedSignal = fft(windowedSignal);
power = FwindowedSignal.*conj(FwindowedSignal)/n;
power_h = 2*power(1:ceil(n/2)+1);
fprintf('Windowed, energy corrected sum of square in frequency domain = %g. \n', sum(power_h));

Subject: when to correct for energy and amplitude in windowed signal spectrum?

From: Nasser Abbasi

Date: 8 Oct, 2010 23:58:42

Message: 2 of 4

A suggestion: Try the DSP newsgroup for DSP specific questions:
comp.dsp

--Nasser


On Oct 8, 4:44 pm, "shinchan Tung" <shinchan75...@gmail.com> wrote:
> When should I multiply the correction factor to a windowed signal? Before FFT or after?  I thought I read it somewhere that ECF is multiplied to the spectrum *AFTER* you do FFT, so I use following code to test how cosistent the estimates of sum of square are in time domain and frequency domain. The code below shows that multiply ECF before FFT is a better estimate than after FFT. I just want to get a confirmation from you experts. Also, is subtracting the mean necessary before FFT?
> Thanks for your help.
>
> t=0:1:279; %test for discontinuity and spectrak leakage.
> Fo = 0.01;
> Fs = 1;
>
> timeseries=cos(2*pi*Fo*t);
> timeseries=timeseries';
> fprintf('Nonwindowed sum of square in time domain = %g. \n', sum(timeseries.^2));
> n=length(timeseries);
> sampling_frequency = Fs;
>
> f = sampling_frequency*(0:ceil(n/2))/n; %f is fraction of sampling freq.
> f = f';
> Ftimeseries = fft(timeseries);
> power = Ftimeseries.*conj(Ftimeseries)/n;
> power_h = 2*power(1:ceil(n/2)+1); % power is symmetric, so multiply the positive frequency side by 2.
>
> fprintf('Nonwindowed sum of square in frequency domain = %g. \n', sum(timeseries.^2));
>
> %multiply timeseries by a Hanning window before FFT.
> windowHanning = window(@hann, n);
> windowedSignal = windowHanning.*timeseries;
> windowedSignal = windowedSignal - mean(windowedSignal);
> fprintf('Windowed sum of square in time domain = %g. \n', sum(windowedSignal.^2));
> FwindowedSignal = fft(windowedSignal);
> power = FwindowedSignal.*conj(FwindowedSignal)/n;
> power_h = 2*power(1:ceil(n/2)+1);
> fprintf('Windowed sum of square in frequency domain = %g. \n', sum(power_h));
>
> %multiply windowed signal by energy correction factor 2/sqrt(1.5) before
> %FFT
>
> windowedSignal = windowedSignal * 2/sqrt(1.5);
> windowedSignal = windowedSignal - mean(windowedSignal);
> fprintf('Windowed, energy corrected sum of square in time domain = %g. \n', sum(windowedSignal.^2));
> FwindowedSignal = fft(windowedSignal);
> power = FwindowedSignal.*conj(FwindowedSignal)/n;
> power_h = 2*power(1:ceil(n/2)+1);
> fprintf('Windowed, energy corrected sum of square in frequency domain = %g. \n', sum(power_h));

Subject: when to correct for energy and amplitude in windowed signal spectrum?

From: dbd

Date: 9 Oct, 2010 04:21:34

Message: 3 of 4

On Oct 8, 4:44 pm, "shinchan Tung" <shinchan75...@gmail.com> wrote:
> When should I multiply the correction factor to a windowed signal? Before FFT or after?
Since the correction, the windowing and the fft are linear operators
the order can be interchanged. (Note that if you move the windowing to
after the fft, the operation becomes a convolution instead of a vector
multiply.)

> Also, is subtracting the mean necessary before FFT?
Whether it might be necessary depends on your application. For your
convenience, note that the DC term out of the fft is defined as the
mean of the time domain inputs and subtracting the mean is a linear
operator.

Dale B. Dalrymple

Subject: when to correct for energy and amplitude in windowed signal spectrum?

From: Greg Heath

Date: 13 Oct, 2010 01:57:13

Message: 4 of 4

On Oct 9, 12:21 am, dbd <d...@ieee.org> wrote:
> On Oct 8, 4:44 pm, "shinchan Tung" <shinchan75...@gmail.com> wrote:> When should I multiply the correction factor to a windowed signal? Before FFT or after?
>
> Since the correction, the windowing and the fft are linear operators
> the order can be interchanged. (Note that if you move the windowing to
> after the fft, the operation becomes a convolution instead of a vector
> multiply.)
>
> > Also, is subtracting the mean necessary before FFT?
>
> Whether it might be necessary depends on your application.

For example, if the mean is much greater than the amplitude
of low frequency components near Fs/N, the sidelobes
from the sinc function transform of the constant mean will
swamp the transforms of the nonzero low frequency
components.

Hope this helps.

Greg

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us