1
$\begingroup$

I need to create 4 different pass-band filters. What remains the same throughout is the following:

Sampling Frequency = $3000Hz$

Pass-band Frequency = $900Hz-1200Hz$

Now, these are the filters I am supposed to create:

  1. $24^{th}$ order FIR using windowing method with Hamming window.

  2. $24^{th}$ order FIR using frequency sampling.

  3. $8^{th}$ order IIR using bilinear transform with Butterworth prototype analogue filter

  4. $8^{th}$ order IIR using impulse invariance with Butterworth prototype analogue filter.

My Attempts:

  1. Normalised frequencies are $0.6$ and $0.8$ and the filter is 24th order hence

    b = fir1(24,[0.6 0.8]);
    
  2. The Desired frequency response is $$H(\Omega)=\exp^{-12j\Omega}$$ for $$\frac{3\pi}{5}\leq\Omega<\frac{4\pi}{5}$$ and $$\frac{6\pi}{5}<\Omega\leq\frac{7\pi}{5}$$ With $$\Omega=\frac{2\pi k}{25}$$ Hence I have that $H(\Omega)\neq0$ when $k=8,9,16,17$

The function in Matlab that creates this filter is

B=fir2(N,f,m)

Where $f$ is the vector with sampled frequencies and $m$ is the magnitude at those frequencies. But for my case I have frequencies higher than $1$ at it says that $f$ starts with $0$ and ends with $1$. I kind of guessed the outcome and produced this:

f=[0 0.64 0.72 1];
m=[1 exp(-12*j*0.64) exp(-12*j*0.72) exp(-12*j)];
b=fir2(24,f,m)

I have a feeling that this is not correct.

  1. For the bilinear IIR I went to matlab's "butter" function.

    [b,a] = butter(4,[0.6 0.8],'stop');
    
  2. For this part I know I need to use both 'butter' and 'impinvar' together but I don't know how.

EDIT / ATTEMPT:

[b1,a1] = butter(4,[2*pi*900 2*pi*1200],'s');
[bz,az] = impinvar(b1,a1,3000);

Could someone tell me if my attempts 1-3 are correct and help me out a little with 4? Thank You.

$\endgroup$

1 Answer 1

3
$\begingroup$

Your call to fir1 looks OK, but you should check the result yourself. You could probably answer several of your other questions by carefully reading the mathworks documentation of the respective functions. E.g., for fir2 you can read that

f is a vector of frequency points in the range from 0 to 1, where 1 corresponds to the Nyquist frequency. The first point of f must be 0 and the last point must be 1. f must be sorted in increasing order. Duplicate frequency points are allowed and are treated as steps in the frequency response.

and

m is a vector containing the desired magnitude response at each of the points specified in f.

So you shouldn't define m as a complex vector; the routine knows the phase lag because it's just half of the filter order. The vector f should be defined as follows:

f = [0 .6 .6 .8 .8 1]

Since this is homework, I leave the definition of the magnitude vector up to you.

Your call to butter looks OK, apart from the fact that you used stop as the filter type. You want a band pass filter, not a band stop filter, so just leave out the additional filter type argument, and the routine will by default design a band pass filter (because there are two edge frequencies in the frequency vector).

For the impulse invariance method, you first have to design an analog Butterworth filter (using butter with last input argument s for analog filter), and then use impinvar to create the corresponding digital filter. The mathworks documentation is very clear, and I think you will succeed after having studied it. Otherwise, add to your original question a very specific question where you're stuck.

$\endgroup$
4
  • $\begingroup$ Thank you very much for helping me out here, that definition of the magnitude is problematic. I am not really sure what is meant here. Could you expand on it for me? Thanks in Advance. $\endgroup$ Dec 17, 2018 at 15:56
  • $\begingroup$ @KuderaSebastian: It's just zeros and ones. At frequencies $0$ and $1$ the corresponding magnitudes are zero (because you want a bandpass, right?). The other $4$ values are the edge frequencies. Starting from the left (low frequencies), you go up from $0$ to $1$, and at the other edge you go down from $1$ to $0$. $\endgroup$
    – Matt L.
    Dec 17, 2018 at 16:00
  • $\begingroup$ Yeah, that was a rather stupid question, but thanks very much for answering. If you could spare another minute, I did attempt part 4 and put it in. Is that what it should look like ? $\endgroup$ Dec 17, 2018 at 16:18
  • $\begingroup$ @KuderaSebastian: Looks good, but also check the resulting filter, if it actually is a band pass with satisfying the specs. $\endgroup$
    – Matt L.
    Dec 17, 2018 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.