Digital filter design with matlab

Discussion in 'Programmer's Corner' started by jut, Dec 14, 2009.

  1. jut

    Thread Starter Senior Member

    Aug 25, 2007
    224
    2
    I'm to design a 2nd order, N=2, butterworth HPF starting from the normalized transfer function for a LPF:

    HN(s)=1/(s^2+1.414*s+1)

    Given:
    T=0.004
    Ωc=0.8 pi
    wc=192 pi

    To find the transfer function of the HPF, substitute s for wc/s:
    H(s)=HN(wc/s)=s^2/(s^2+853*s+363833)

    Here's my MATLAB code:

    Code ( (Unknown Language)):
    1. T=.8/192;
    2. Fs=1/T;
    3. nums=[1 0 0];
    4. dens=[1 853.03 363833.1];
    5.  
    6. figure
    7. [Hws,w]=freqs(nums,dens);
    8. plot(w,abs(Hws))
    9.  
    10. [numz,denz]=impinvar(nums,dens,Fs);
    11. tf(numz,denz,T)
    12. figure
    13. [Hwz,w]=freqz(numz,denz);
    14. plot(w,abs(Hwz))
    The transfer function of my analog filter looks good, but the transfer function of the digital filter is not right. Could someone help please?
     
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    What is this line doing:

    ... You don't assign it to anything.
     
  3. jut

    Thread Starter Senior Member

    Aug 25, 2007
    224
    2
    That line display the digital transfer function, H(z):

    Transfer function:
    -3.55 z^2 - 0.1229 z + 0.0001192
    --------------------------------
    z^2 + 0.06931 z + 0.0286

    Sampling time: 0.0041667
     
Loading...