DSPRelated.com
Forums

Windowing in the Frequency Domain

Started by mark...@gmail.com December 31, 2009
Hello!

I'm trying to show the effects of windowing in the frequency domain in MATLAB, but i'm rather stuck at doing so.

Precisely, i've problems of getting the theory (convolution H_idealfilter & H_window) to work in the "discrete world" of MATLAB. From what I understand after reading some books on this topic, I need circular convolution, am I right? (btw: anyone knows good papers/books, code examples,... for this topic? nearly everything I found focuses on the time domain)
But even if I'm right concerning the circular convolution, I just don't get my program to work proberly.

This is my code so far:

N24; %number of fft samples
f1=-1:2/(N-1):1; %for the index of the plots
L=floor(N*0.25); %get a cutoff frequency this way??
MQ;
window=rectwin(M);
x1tshift((fft(window,N))')/sum(window);%fft the window, normalise and shift the window
x2=[zeros(1,N/2-L/2) ones(1,L) zeros(1,N/2-L/2)]; %frequency response of a ideal low pass
convonv(x1,x2,N); %do the circular convolution
plot(handles.conv_demo_axes,f1,x1,'k',f1,x2,'r'); %plot the window and the ideal low pass in the frequency domain
plot(handles.convolution_axes,f1,20*log10(abs(convo)));%log plot of the filter

After plotting this, it just doesn't look like a low pass filter for this window (or am i wrong and i just made mistakes concerning normalising and plotting). The first plot doesn't look this much wrong after comparing it with for example [Morgan, Claypool]DSP for Matlab and Labview Vol III p. 48

Hope I managed to explain my problem, I'm thankful for any help!

-Mark
Hi!

Thank you for the help, but i just don't get why my ouput should be right.
When I compare it with the multiplication in the frequency domain +fft on that (e. g. the normal way you do filter design, it just looks completely different). Moreover, if i take the angle() of my frequency domain convolution result, it doesn't look like it has linear phase, which it should have.

Here my code once again didn't find the other post:
N24; %number of fft samples
f1=-1:2/(N-1):1; %for the index of the plots
L=floor(N*0.25); %get a cutoff frequency this way??
MQ;
window=rectwin(M);
x1tshift((fft(window,N))')/sum(window);%fft the window, normalise and shift
the window
x2=[zeros(1,N/2-L/2) ones(1,L) zeros(1,N/2-L/2)]; %frequency response of a ideal
low pass
convonv(x1,x2,N); %do the circular convolution
plot(handles.conv_demo_axes,f1,x1,'k',f1,x2,'r'); %plot the window and the ideal
low pass in the frequency domain
plot(handles.convolution_axes,f1,20*log10(abs(convo)));%log plot of the filter

when i plot
abs(fft(x1.*x2,N) it looks a lot more like a filter response than the above answer. Shouldn't/Mustn't it look similar?
I'm afraid there is some trivial misunderstanding or error i just don't get...

Thanks for any help,
Mark

Hello Mark,
>�
>The output seems to be okay. I don't see any problem with it. May be you should remove the db conversion part and see the output.
>�
>plot(handles. convolution_ axes,f1, 20*log10(abs( convo))); %log plot of the filter
>
>Also, the confusion could be because of the x-axis being viewed from 0 to Fs (0 to N) and not from -Fs/2 to Fs/2 (-N/2 to N/2).
>�
>Hope this helps.
>�
>Regards,
>Rajmathi S.
>
>