Richard Owlett <

[email protected]> wrote in message news:<

[email protected]>...

> This is intentionally "dumb" question.

> I suspect a good answer will illuminate a fallacy in my thinking.

>

> assume a real input

> perform FFT

> set all bins to 0 that are outside pass band

> perform suitably scaled IFFT

>

> What's wrong with this picture?
It's nothing inherently wrong. The problem is that the filter is only

partially specified. A matlab exercise might iluminate the problem.

I'll plot an ideal brick-wall magnitude response, design a frequency-

domain filter from that, and plot the true frequency response for

the realized filter.

The exercise is, unfortunately, in matlabese.

%%%%%%%%%%%%% Begin matlab script %%%%%%%%%%%%%%%%%%%

clear % Clear workspace

clf % Clear current figure

fc= 0.25; % Cut-off frequency (fs = 1)

N = 32; % Number of taps in FIR filter.

Nfft=1024; % Number of points in interpolated spectrum

% Plot Brick-wall filter, ideal response in blue color, thick line

plot([0 fc, fc, 1-fc,1-fc,1],[1 1 0 0 1 1],'b','linewidth',3')

% Adjust axes of plot

axis([0 1 0 1.5])

% Specify that further plots should go on top of the current one

hold on

% Specify magnitude spectrum for N-tap 'brick-wall' filter

fv=[0:N-1]/N;

Hbw=zeros(N,1);

idx=find((fv<=fc)|(fv>=1-fc));

if ~isempty(idx)

Hbw(idx)=ones(length(idx),1);

end

% Plot samples on top of ideal response as large, red x'es.

plot(fv,Hbw,'xr','markersize',14,'linewidth',2)

% Compute interpolated frequency spectrum: Perform IFFT

% to find impulse response N-tap 'brick-wall' filter,

% re-arrange coefficients, then compute interpolated DFT

% by zero-padding impulse response and computing DFT.

hbw=ifft(Hbw);

% Rearrange coefficients in impulse response. Matlab users

% should use the function FFTSHIFT here.

hbw=[hbw(N/2+1:N);hbw(1:N/2)];

% Plot interpolated spectrum in green

fvzp=[0:Nfft-1]/Nfft;

plot(fvzp,abs(fft(hbw,Nfft)),'g','linewidth',2)

% Bring figure to the foreground

figure(gcf)

%%%%%% End matlab script %%%%%%%%%%%%%%%%%%%%%%%%%

When you get this to run, you will see that the FIR filter response

(the green line) coincides with the ideal brick-wall response (the blue

line) only at a finite number of pints (the red x'es). Since you can

only specify the filter response at a finite number of points, you

can get as close to the ideal response as you like (except for the Gibbs

phenomenon), but you can't get all the way, and the actual response

deviates from the required response in the intervals between

specifications.

Rune