DSPRelated.com
Forums

Hamming window

Started by rajgerman February 19, 2006
"rajgerman" <rajgerman@msn.com> wrote in message 
news:MvOdnVwHToa4QWTenZ2dnUVZ_sadnZ2d@giganews.com...
> >What Fred and I each have said, is that you may either: >> >>1) multiply your data on a sample by sample basis by the samples > comprising >>the Hamming window and then FFT the product. >> >>or >> >> >>2) convolve your FFTed data with the 3 coefs -0.23, 0.54, -0.23 that are > >>the frequency domain version of the Hamming window. You will need to know > >>how your FFT orders its data so the convolution can be applied properly. >> >> > > Cheers Clay > > I think I much better idea now. How would I though convolve the FFTed data > with the 3 coefs -0.23, 0.54, -0.23?? > > My FFTed data is Y = fft(y);
In matlabese: FFTed Hamming window W = fft(w) = [-0.23 0.54 -0.23] where "w" is the Hamming window for the length of the sequence .. same length as length(y) conv(W,Y) Fred
"Bob Cain" <arcane@arcanemethods.com> wrote in message 
news:dtd4vh0a6a@enews2.newsguy.com...
>> >> Since the Hamming window is defined in terms of cosines, the Freq domain >> version turns out to have only 3 non-zero coefs. This makes for a pretty >> easy convolution. The coefs are -0.23, 0.54, -0.23 > > The three coeficients aren't real are they? The center one is but I seem > to remember that the side ones were complex. False memory? > > > Bob > --
Hello Bob, Yes the 3 coefs are real since the Hamming window is defined as Hamming(n,N) = 0.54-0.46*cos(2*pi*n/N) And by inspection one can see we have a DC term and a cosine term. Since both of these are even functions, The hermitian symmetry relations tell us that the Fourier transform wil be purely real. Now there is a point of hair splitting with the defn in that if we let "n" go from 0 to N in the Hamming window defn, then we are mixing the idea of N+1 samples into something that has period N. And this can lead to the components associated with frequencies of -1 and 1 having complex coefs although the imaginary parts will be small for N not small. If I use the 1st N terms from the Hamming defn, then its FT (period N) is purely real with only three nonzero terms. If I use N+1 terms and then FT them (with period N+1), I will get complex data across the whole range with just 3 terms being non-negligible. Clay
> >> >> Cheers Clay >> >> I think I much better idea now. How would I though convolve the FFTed
data
>> with the 3 coefs -0.23, 0.54, -0.23?? >> >> My FFTed data is Y = fft(y); > > > >If your FFT is like most, the output vector is in an order like > >0,1,2,3,...,N/2,-N/2+1,-N/2+2,-N/2+3,...-3,-2,-1 > >where the numbers above are the frequencies. Other FFTs may have the
output
>in an order like > >-N/2+1,-N/2+2,-N/2+3,...,-3,-2,-1,0,1,2,3,...,N/2 > >In both of these cases I've assumed the length N is even. You will need
to
>know how yours is done. > > >Now the convolution goes likes this > >new H(0) equals 0.54*H(0) - 0.26*(H(-1)+H(1)) > >new H(1) equals 0.54*H(1) - 0.26*(H(0)+H(2)) > >new H(2) equals 0.54*(H(2) - 0.26*(H(1)+H(3)) > >and so on. Whenever the index exceeds N/2 just wrap it back around. For >example N/2+1 becomes -N/2+1. Be careful to not use the new value as an >input in one of the calculations. All of the inputs are the old values. > > >IHTH, >Clay
My ffted data are all complex values. size(Y) = ans = 88200 1 These are the first 10 values of my ffted data: 0.0001 - 0.0000i 0.0002 + 0.0001i 0.0000 + 0.0001i -0.0000 + 0.0001i -0.0000 - 0.0000i 0.0001 + 0.0001i -0.0002 + 0.0001i 0.0000 - 0.0000i 0.0000 - 0.0000i 0.0002 + 0.0002i So does that mean H(0) = 0.0001 - 0.0000i and so on .........??
>Hi there, > >I you plan on analyzing your signal in MATLAB then you can use the >function PWELCH to estimate the power spectrum density of your signal. >This function automatically implements the hanning window and estimates >the PSD for you (as well as plot it): > >http://www.mathworks.com/access/helpdesk/help/toolbox/signal/pwelch.html > >This estimate is much better than a simple periodogram. Note that you >need the Signal Processing Toobox to use it... > >You can send me the files if you want me to take a look. > >-ikaro > >
Cheers Ikaro For now I have to use the hamming window. But later on I will make use of the welch method. Are the Hann/Hanning and Hamming window the same thing?? I have read that they are almost similar.
On Mon, 20 Feb 2006 11:36:13 -0500, "Clay S. Turner"
<Physics@Bellsouth.net> wrote:

> >> >> Cheers Clay >> >> I think I much better idea now. How would I though convolve the FFTed data >> with the 3 coefs -0.23, 0.54, -0.23?? >> >> My FFTed data is Y = fft(y); > > > >If your FFT is like most, the output vector is in an order like > >0,1,2,3,...,N/2,-N/2+1,-N/2+2,-N/2+3,...-3,-2,-1 > >where the numbers above are the frequencies. Other FFTs may have the output >in an order like > >-N/2+1,-N/2+2,-N/2+3,...,-3,-2,-1,0,1,2,3,...,N/2 > >In both of these cases I've assumed the length N is even. You will need to >know how yours is done. > > >Now the convolution goes likes this > >new H(0) equals 0.54*H(0) - 0.26*(H(-1)+H(1)) > >new H(1) equals 0.54*H(1) - 0.26*(H(0)+H(2)) > >new H(2) equals 0.54*(H(2) - 0.26*(H(1)+H(3)) > >and so on. Whenever the index exceeds N/2 just wrap it back around. For >example N/2+1 becomes -N/2+1. Be careful to not use the new value as an >input in one of the calculations. All of the inputs are the old values. > > >IHTH, >Clay
Hi Clay, I sure like your description. Very nice. We might also mention to rajgerman that: (1) if he uses a hanning window, the freq-domain convolutions can performed with binary right shifts and avoid multiplications altogether. (2) this freq-domain convolution idea can be extended to use the three-term Blackman window (and the "three-term Blackman-Harris" window). These windows have five non-zero freq-domain coefficients but they also have much lower sidelobes (reduced spectral leakage) than the Hamming window. See Ya', [-Rick-]
Bob Cain <arcane@arcanemethods.com> wrote in
news:dtd4vh0a6a@enews2.newsguy.com: 

> > > Clay S. Turner wrote: >>> It's not likely that you want to window the FFTd sequence - as in >>> multiply the FFTd sequence. >>> It's much more likely that you want(ed) to window the temporal >>> sequence (as in multiply) before the FFT. >>> Or you could convolve in frequency to get the same affect. >>> >>> FFT both the temporal data sequence and the temporal window. >>> Convolve the two in frequency. >>> >> >> Hello Fred, >> >> Since the Hamming window is defined in terms of cosines, the Freq >> domain version turns out to have only 3 non-zero coefs. This makes >> for a pretty easy convolution. The coefs are -0.23, 0.54, -0.23 > > The three coeficients aren't real are they? The center one is but I > seem to remember that the side ones were complex. False memory? > Bob
No, just shit for brains.
Sokolich wrote:
> Bob Cain <arcane@arcanemethods.com> wrote in > news:dtd4vh0a6a@enews2.newsguy.com: > > > ... False memory? > > No, just shit for brains.
more unprovoked ad hominem. Gary, the only one embarassed here (or who should be) is you. r b-j
Thanks guys I have understood the hamming window and also have implemented
it.

I'm having difficulty labelling my axis. I have converted the complex
numbers of ffted data (X) to real values by applying the conjugate (Z).

I'm having difficulty labelling and converting my x axis. I need to
represent it in frequency terms. 

Data = Z
Sample rate = 44100Hz
Total no. of frequencies/values of data = 88200
Length of signal = 2 seconds

I have also applied fftshift to the data (Z) so that my left half is
negative and the right half is positive.

How can I represent the x-axis in frequency terms??

If someone could also tell me how I will be able to get rid of certain
frequencies e.g. I want everything below 20Hz to be cut off/throw it
away??
"robert bristow-johnson" <rbj@audioimagination.com> wrote in 
news:1140664170.878898.308540@g47g2000cwa.googlegroups.com:

> > Sokolich wrote: >> Bob Cain <arcane@arcanemethods.com> wrote in >> news:dtd4vh0a6a@enews2.newsguy.com: >> >> > ... False memory? >> >> No, just shit for brains. > > more unprovoked ad hominem.
Ad hominem, yes, but certainly not unprovoked. But then, to those of you who admire this scumbag, bob cain's history of truly unprovoked ad hominem attacks atainst me is irrelevant and immaterial.
> Gary, the only one embarassed here (or who should be) is you. > r b-j
It will take a hell of lot more than a blatantly biased and ignorant comment from a bob-cain ass-kisser like you before I get anywhere near close to being embarassed.
"rajgerman" <rajgerman@msn.com> wrote in message 
news:0eCdnVM_-79bTZzZRVn-pg@giganews.com...
> Thanks guys I have understood the hamming window and also have implemented > it. > > I'm having difficulty labelling my axis. I have converted the complex > numbers of ffted data (X) to real values by applying the conjugate (Z).
Why?
> > I'm having difficulty labelling and converting my x axis. I need to > represent it in frequency terms. > > Data = Z > Sample rate = 44100Hz > Total no. of frequencies/values of data = 88200 > Length of signal = 2 seconds
Each frequency value is 1/(Length of signal) apart = 1/2 Hz. This is also understood from sample rate 44100 divided by number of values 88200 = 44100Hz / 88200samples = 0.5Hz/sample Actually, because things are sampled I try to keep track by understanding "data points or samples" AND "intervals" So, 44100 sample rate for 2 seconds starts at time=0 and ends at time = (2-1/44100). There are 44100-1 intervals in between but normal assumptions add an interval after the last sample (and then the sequence is assumed to repeat). So, then there are 44100 intervals that encompass 2 seconds.
> > I have also applied fftshift to the data (Z) so that my left half is > negative and the right half is positive.
Why? The normal representation is from zero to fs/2 and from fs-fs/2 to fs which is the same as from -fs/2 to zero. So it goes from zero to fs-fs/(length of signal) and is assumed to repeat at fs with F(fs) = F(0).
> > How can I represent the x-axis in frequency terms?? >
As above.
> If someone could also tell me how I will be able to get rid of certain > frequencies e.g. I want everything below 20Hz to be cut off/throw it > away??
High pass filter. If you're doing it in the frequency domain then it's best to multiply by the complex frequency response of an actual FIR filter - not just multiply by zero where you want things to go away. Fred