FIR filter using windowed impulse response
h = window(d,fcnhndl,fcnarg)
h = window(d,win)
h = window(d,fcnhndl,fcnarg) designs an FIR filter using the specifications in filter specification object d. Depending on the specification type of d, the returned filter is either a single-rate digital filter — a dfilt, or a multirate digital filter — an mfilt.
fcnhndl is a handle to a filter design function that returns a window vector, such as the hamming or blackman functions. fcnarg is an optional argument that returns a window. You pass the function to window. Refer to example 1 in the following section to see the function argument used to design the filter.
h = window(d,win) designs a filter using the vector you supply in win. The length of vector win must be the same as the impulse response of the filter, which is equal to the filter order plus one. Example 2 shows this being done.
These examples design filters using the two design techniques of specifying a function handle or passing a window vector as an input argument.
Use a function handle and optional input arguments to design a multirate filter. We use a function handle to hamming to provide the window. Since this example creates a decimator filter specifications object, window returns a multirate filter.
d = fdesign.decimator(4,'lowpass','N,Fc',30,1000,10000); % Lowpass decimator with a 6-dB down frequency of 1 kHz % Order equal to 30 and sampling frequency 10 kHz Hd =window(d,'window',@hamming); fvtool(Hd)
Use a window vector provided by the kaiser window function to design a Nyquist filter. The window length must be the filter order plus one. .
d = fdesign.nyquist(5,'n',150); % Kaiser window with beta parameter 2.5 Hd = window(d,'window',kaiser(151,2.5)); fvtool(Hd)