DSPRelated.com
Forums

Time derivative of Blackman window

Started by adamchapman January 15, 2009
Hi,

I've made a Blcakman window in Matlab with the code:

windowWidth=256;
Window=(0:windowWidth)/windowWidth;
Window=0.42-0.5*cos(2*pi*adaWindow)+0.08*cos(4*pi*adaWindow);

This looks fine when I plot it, But Im not sure wether how to
calculate the time derivative of it. An fft of the Window variable
gives just a single peak and a flat line, and

gradient(Window)*Fs

doesn't look right either.

I assume the time derivative looks like this:
http://en.wikipedia.org/wiki/File:Window_function_(blackman).png


Any help is greatly appreciated

Adam
On Jan 15, 11:29&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk>
wrote:
> Hi, > > I've made a Blcakman window in Matlab with the code: > > windowWidth=256; > Window=(0:windowWidth)/windowWidth; > Window=0.42-0.5*cos(2*pi*adaWindow)+0.08*cos(4*pi*adaWindow); > > This looks fine when I plot it, But Im not sure wether how to > calculate the time derivative of it. An fft of the Window variable > gives just a single peak and a flat line, and > > gradient(Window)*Fs > > doesn't look right either. > > I assume the time derivative looks like this:http://en.wikipedia.org/wiki/File:Window_function_(blackman).png > > Any help is greatly appreciated > > Adam
Silly mistake. FFT looks right when plotting with a log scale. However, in order to get a frequency response like the wikipedia picture, I need to use a LOT of zero padding. Is the zero padding normally necessary?
On Jan 15, 11:35&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk>
wrote:
> On Jan 15, 11:29&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk> > wrote: > > > > > > > Hi, > > > I've made a Blcakman window in Matlab with the code: > > > windowWidth=256; > > Window=(0:windowWidth)/windowWidth; > > Window=0.42-0.5*cos(2*pi*adaWindow)+0.08*cos(4*pi*adaWindow); > > > This looks fine when I plot it, But Im not sure wether how to > > calculate the time derivative of it. An fft of the Window variable > > gives just a single peak and a flat line, and > > > gradient(Window)*Fs > > > doesn't look right either. > > > I assume the time derivative looks like this:http://en.wikipedia.org/wiki/File:Window_function_(blackman).png > > > Any help is greatly appreciated > > > Adam > > Silly mistake. FFT looks right when plotting with a log scale. > However, in order to get a frequency response like the wikipedia > picture, I need to use a LOT of zero padding. Is the zero padding > normally necessary?- Hide quoted text - > > - Show quoted text -
Oh dear, stuck again. Basically Im trying to find the fft of a time derivative. To get the normal fft, I multiply part of the signal (which is an audio signal) by a Blackman window, then perform an fft, i.e.: %standard fft frame=signal.*blackman; S=fft(frame); now i need an fft of the signal multiplied by the "time derivative of the window": %derivative d_window=fft(blackman); %time derivative of blackman window d_S=fsignal.*fft(d_window); I this correct, or do I need to scale or shift the "d_window" function ?
On Jan 15, 11:54&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk>
wrote:
> On Jan 15, 11:35&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk> > wrote: > > > > > > > On Jan 15, 11:29&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk> > > wrote: > > > > Hi, > > > > I've made a Blcakman window in Matlab with the code: > > > > windowWidth=256; > > > Window=(0:windowWidth)/windowWidth; > > > Window=0.42-0.5*cos(2*pi*adaWindow)+0.08*cos(4*pi*adaWindow); > > > > This looks fine when I plot it, But Im not sure wether how to > > > calculate the time derivative of it. An fft of the Window variable > > > gives just a single peak and a flat line, and > > > > gradient(Window)*Fs > > > > doesn't look right either. > > > > I assume the time derivative looks like this:http://en.wikipedia.org/wiki/File:Window_function_(blackman).png > > > > Any help is greatly appreciated > > > > Adam > > > Silly mistake. FFT looks right when plotting with a log scale. > > However, in order to get a frequency response like the wikipedia > > picture, I need to use a LOT of zero padding. Is the zero padding > > normally necessary?- Hide quoted text - > > > - Show quoted text - > > Oh dear, stuck again. > Basically Im trying to find the fft of a time derivative. > > To get the normal fft, I multiply part of the signal (which is an > audio signal) by a Blackman window, then perform an fft, i.e.: > > %standard fft > frame=signal.*blackman; > S=fft(frame); > > now i need an fft of the signal multiplied by the "time derivative of > the window": > > %derivative > d_window=fft(blackman); %time derivative of blackman window > d_S=fsignal.*fft(d_window); > > I this correct, or do I need to scale or shift the "d_window" > function ?- Hide quoted text - > > - Show quoted text -
do I also need to use only the first half of the d_S data since the fft output is always reflected?
On Jan 15, 12:39&#4294967295;pm, adamchapman <adamchapman1...@hotmail.co.uk>
wrote:
> On Jan 15, 11:54&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk> > wrote: > > > > > > > On Jan 15, 11:35&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk> > > wrote: > > > > On Jan 15, 11:29&#4294967295;am, adamchapman <adamchapman1...@hotmail.co.uk> > > > wrote: > > > > > Hi, > > > > > I've made a Blcakman window in Matlab with the code: > > > > > windowWidth=256; > > > > Window=(0:windowWidth)/windowWidth; > > > > Window=0.42-0.5*cos(2*pi*adaWindow)+0.08*cos(4*pi*adaWindow); > > > > > This looks fine when I plot it, But Im not sure wether how to > > > > calculate the time derivative of it. An fft of the Window variable > > > > gives just a single peak and a flat line, and > > > > > gradient(Window)*Fs > > > > > doesn't look right either. > > > > > I assume the time derivative looks like this:http://en.wikipedia.org/wiki/File:Window_function_(blackman).png > > > > > Any help is greatly appreciated > > > > > Adam > > > > Silly mistake. FFT looks right when plotting with a log scale. > > > However, in order to get a frequency response like the wikipedia > > > picture, I need to use a LOT of zero padding. Is the zero padding > > > normally necessary?- Hide quoted text - > > > > - Show quoted text - > > > Oh dear, stuck again. > > Basically Im trying to find the fft of a time derivative. > > > To get the normal fft, I multiply part of the signal (which is an > > audio signal) by a Blackman window, then perform an fft, i.e.: > > > %standard fft > > frame=signal.*blackman; > > S=fft(frame); > > > now i need an fft of the signal multiplied by the "time derivative of > > the window": > > > %derivative > > d_window=fft(blackman); %time derivative of blackman window > > d_S=fsignal.*fft(d_window); > > > I this correct, or do I need to scale or shift the "d_window" > > function ?- Hide quoted text - > > > - Show quoted text - > > do I also need to use only the first half of the d_S data since the > fft output is always reflected?- Hide quoted text - > > - Show quoted text -
Adam, Reading the chain of messages I think you're using a sledgehammer (Matlab) to crack a nut (your data). You are asking questions that can easily be answered by Googling or looking in an introductory DSP text book. Using Excel is usually frowned upon but I find it really useful to get my head around what happens to discrete time signals when you FFT them, how Windows (like your Blackman) can improve the result, how the frequency domain data is reflected, what happens at DC - that kind of thing. It's really easy to plot the results so you can see for yourself what is happening. Read a bit, have a play in Excel, read a it more - you'll soon get your head around it. When you know in your own mind what the results should look like - only then try doing it in Matlab. In fact, you might find Excel can do what you want anyway. Matlab has got lots of in-built signal processing functions but if you've never done this kind of thing before, you won't learn how they work or what the result should look like - you need to do a few simple examples 'long hand' before you try and use these shortcuts. I normally make some fake data (nice sine waves) in the spreadsheet and then use the Fourier analysis tool (in data analysis tools) to see what happens. Dead easy. If you struggle to make your own sine wave data in Excel then you need to stop what you are doing and go back a step in your reading. All the information is out there for you to discover so you should be up and running in no time. I'm making a big assumption that you've got Excel but if you've got Matlab then you should be able to purchase Excel with the small change down the back of your sofa! Cheers, Andy
Andy P wrote:

   ...

> I'm making a big assumption that you've got Excel but if you've got > Matlab then you should be able to purchase Excel with the small change > down the back of your sofa!
Open Office is free and has Microsoft Office's capabilities. http://openoffice-software.com/new/home/ Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Jan 15, 3:22&#4294967295;pm, Jerry Avins <j...@ieee.org> wrote:
> Andy P wrote: > > &#4294967295; &#4294967295;... > > > I'm making a big assumption that you've got Excel but if you've got > > Matlab then you should be able to purchase Excel with the small change > > down the back of your sofa! > > Open Office is free and has Microsoft Office's capabilities.http://openoffice-software.com/new/home/ > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
I don't like to pay for software either - only problem is there is no FFT function in the Open Office spreadsheet. I think it's something they intend to add in later releases but it's not in 3.0. You have reminded me that there is a free alternative spreadsheet if you're running Linux that will do an FFT - Gnumeric. There are also free alternatives to Matlab like Octave and Scilab but as I said before, far better to work through a few simple examples at a low level to get your head around what is going on - then move up to something more powerful with the functions built in. Andy
..... alternatively, I guess you don't need built in FFT functions -
use Open Office and do your FFTs long hand too.  I think it can deal
with complex numbers so it should be possible - never tried it....

Andy

adamchapman wrote:
> On Jan 15, 11:54 am, adamchapman <adamchapman1...@hotmail.co.uk> > wrote: >> On Jan 15, 11:35 am, adamchapman <adamchapman1...@hotmail.co.uk> >> wrote: >> >> >> >> >> >>> On Jan 15, 11:29 am, adamchapman <adamchapman1...@hotmail.co.uk> >>> wrote: >> >>>> Hi, >> >>>> I've made a Blcakman window in Matlab with the code: >> >>>> windowWidth=256; >>>> Window=(0:windowWidth)/windowWidth; >>>> Window=0.42-0.5*cos(2*pi*adaWindow)+0.08*cos(4*pi*adaWindow); >> >>>> This looks fine when I plot it, But Im not sure wether how to >>>> calculate the time derivative of it. An fft of the Window variable >>>> gives just a single peak and a flat line, and >> >>>> gradient(Window)*Fs >> >>>> doesn't look right either. >> >>>> I assume the time derivative looks like >>>> this:http://en.wikipedia.org/wiki/File:Window_function_(blackman).png >> >>>> Any help is greatly appreciated >> >>>> Adam >> >>> Silly mistake. FFT looks right when plotting with a log scale. >>> However, in order to get a frequency response like the wikipedia >>> picture, I need to use a LOT of zero padding. Is the zero padding >>> normally necessary?- Hide quoted text - >> >>> - Show quoted text - >> >> Oh dear, stuck again. >> Basically Im trying to find the fft of a time derivative. >> >> To get the normal fft, I multiply part of the signal (which is an >> audio signal) by a Blackman window, then perform an fft, i.e.: >> >> %standard fft >> frame=signal.*blackman; >> S=fft(frame); >> >> now i need an fft of the signal multiplied by the "time derivative of >> the window": >> >> %derivative >> d_window=fft(blackman); %time derivative of blackman window >> d_S=fsignal.*fft(d_window); >> >> I this correct, or do I need to scale or shift the "d_window" >> function ?- Hide quoted text - >> >> - Show quoted text - > > do I also need to use only the first half of the d_S data since the > fft output is always reflected?
This is a bit confusing because you keep referring to the time derivative of the window but then introduce the FFT. Why? The process using the FFT appears to simply be frequency domain multiplication in place of time domain convolution (without the IFFT step). There's no time derivative involved in what you show. The images are of the window and its *Fourier Transform*. If you use a DFT or FFT then, yes you have to zero pad like crazy to see all the detail of the frequency response of the window itself. No, you don't use half of a symmetrical function. The standard Blackman window in discrete form is: w(n) = a0 - a1*cos[2pi*n / (N-1)] + a2*cos[4pi*n / (N-1)] Now, ignoring the niceties of the indices of this discrete function, I would differentiate it as if it were a continuous function and then sample it. I believe this results in: a1*sin[2pi*n / (N-1)] - a2*cos[4pi*n / (N-1)] This would be a sampled version of the time derivative of the continuous Blackman window. I'm sure you can check my ability to differentiate, eh? Just out of curiosity, why do you want the time derivative of the window? Or, did I miss something like a factor of (jw) in frequency? In the continuous world, multiplying by jw in frequency is equivalent to taking the derivative in time if one is talking about Fourier Transform pairs as we often do. Fred
On Jan 15, 4:04&#4294967295;pm, "Fred Marshall" <fmarshallx@remove_the_x.acm.org>
wrote:
> adamchapman wrote: > > On Jan 15, 11:54 am, adamchapman <adamchapman1...@hotmail.co.uk> > > wrote: > >> On Jan 15, 11:35 am, adamchapman <adamchapman1...@hotmail.co.uk> > >> wrote: > > >>> On Jan 15, 11:29 am, adamchapman <adamchapman1...@hotmail.co.uk> > >>> wrote: > > >>>> Hi, > > >>>> I've made a Blcakman window in Matlab with the code: > > >>>> windowWidth=256; > >>>> Window=(0:windowWidth)/windowWidth; > >>>> Window=0.42-0.5*cos(2*pi*adaWindow)+0.08*cos(4*pi*adaWindow); > > >>>> This looks fine when I plot it, But Im not sure wether how to > >>>> calculate the time derivative of it. An fft of the Window variable > >>>> gives just a single peak and a flat line, and > > >>>> gradient(Window)*Fs > > >>>> doesn't look right either. > > >>>> I assume the time derivative looks like > >>>> this:http://en.wikipedia.org/wiki/File:Window_function_(blackman).png > > >>>> Any help is greatly appreciated > > >>>> Adam > > >>> Silly mistake. FFT looks right when plotting with a log scale. > >>> However, in order to get a frequency response like the wikipedia > >>> picture, I need to use a LOT of zero padding. Is the zero padding > >>> normally necessary?- Hide quoted text - > > >>> - Show quoted text - > > >> Oh dear, stuck again. > >> Basically Im trying to find the fft of a time derivative. > > >> To get the normal fft, I multiply part of the signal (which is an > >> audio signal) by a Blackman window, then perform an fft, i.e.: > > >> %standard fft > >> frame=signal.*blackman; > >> S=fft(frame); > > >> now i need an fft of the signal multiplied by the "time derivative of > >> the window": > > >> %derivative > >> d_window=fft(blackman); %time derivative of blackman window > >> d_S=fsignal.*fft(d_window); > > >> I this correct, or do I need to scale or shift the "d_window" > >> function ?- Hide quoted text - > > >> - Show quoted text - > > > do I also need to use only the first half of the d_S data since the > > fft output is always reflected? > > This is a bit confusing because you keep referring to the time derivative of > the window but then introduce the FFT. &#4294967295;Why? > > The process using the FFT appears to simply be frequency domain > multiplication in place of time domain convolution (without the IFFT step). > There's no time derivative involved in what you show. > > The images are of the window and its *Fourier Transform*. &#4294967295;If you use a DFT > or FFT then, yes you have to zero pad like crazy to see all the detail of > the frequency response of the window itself. > > No, you don't use half of a symmetrical function. > > The standard Blackman window in discrete form is: > > w(n) = a0 - a1*cos[2pi*n / (N-1)] + a2*cos[4pi*n / (N-1)] > > Now, ignoring the niceties of the indices of this discrete function, I would > differentiate it as if it were a continuous function and then sample it. &#4294967295;I > believe this results in: > > a1*sin[2pi*n / (N-1)] - a2*cos[4pi*n / (N-1)] > > This would be a sampled version of the time derivative of the continuous > Blackman window. &#4294967295;I'm sure you can check my ability to differentiate, eh? > > Just out of curiosity, why do you want the time derivative of the window? > > Or, did I miss something like a factor of (jw) in frequency? > In the continuous world, multiplying by jw in frequency is equivalent to > taking the derivative in time if one is talking about Fourier Transform > pairs as we often do. > > Fred- Hide quoted text - > > - Show quoted text -
Thanks to all of you. Looks like you were right Fred, Im getting much more reasonable data now. Good job of keepin me on my toes with the differentiation- I noticed the second term should be -ve sine! To satisfy your interest, I'm looking for instantaneous frequency. To get this, you need to use the derivative of your windowing function. i.e. fft(signal.*d_window) rather than the usual fft(signal*window) Thanks again Adam