Manually Windowing an IIR Filter in Matlab I am currently trying to window an analog IIR filter in order to obtain an FIR filter. Though I realize the fir1 function exists within Matlab, I was wondering to see if it could be done step-by-step to produce a notch filter at 0 Hz to eliminate any DC gains in the system. However, I quickly realized that I may not know what I'm doing :)

Firstly, I created a butterworth filter containing the characteristics that I'm looking for just for a comparison. Once the Chebyshev II analog filter was created, the magnitude and phase response was viewed. It doesn't show a bandstop at 0 Hz, but my guess is because it hasn't yet been windowed to show this result? I also wasn't too sure how to combine the window and analog filter, and would love it if someone pointed me in the right direction :(

Fs = 250;
n = 5; 
Rs = 40; 
Wn = [0.1*2/Fs, 0.2*2/Fs];
[b0,a0] = butter(3,Wn,'stop');
[b1,a1] = cheby2(n,Rs,Wn,'stop','s');
freqz(b0, a0, 4096, Fs);
w = triang(250);  
y = filter(b1,a1,w);
In the classical world of digital filters, an infinite impulse response (IIR) filter is used for its computational efficiency while achieving supreme performance compared to a finite impulse response (FIR) filter. 

Usually, implementing an IIR filter happens in the time domain, with an architecture of direct form-I, II or else which provides a solution of the linear constant coefficient difference equation (LCCDE) describing the filter.

$$
\sum_{k=0}^{N} a[k]y[n-k] = \sum_{k=0}^{M} b[k]x[n-k]
$$

which is typically called an $N^{th}$ order LCCDE.

However, when there happens a need for implementing the IIR filter using time domain convolution instead;

$$
y[n] = h[n] \star x[n]
$$ 

then this requires the practical availability of the impulse response $h[n]$ of the IIR filter which is infinite length by definition. 

To obtain a finite length, FIR, approximation $h[n]$ to the IIR digital filter, first choose your analog prototype filter, then apply the necessary transforms to get the digital IIR equivalent filter coefficients $a[k]$ and $b[k]$, and compute the truncated impulse response $h[n]$ of this filter, from $a[k]$ and $b[k]$ to a length that's adequate for the purpose of application and finally apply a further windowing to $h[n]$ if that's necessary...

The following MATLAB/OCTAVE command will give you a length $N$ truncated impulse response from IIR coefficients $a[k]$ and $b[k]$ with zero initial conditions.

h = filter(b,a,[1 zeros(1,N-1)]);