Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab: Butterworth Filter Bode Plot

  1. Sep 25, 2012 #1
    I'm stuck on a really simple problem because I haven't done matlab in a while. I have transfer functions for nth order lowpass Butterworth Filters:
    H(jw) = 1/(s + w_c)^n

    I want to plot the 1st to 5th order filters. How do I input H(jw) into matlab? The tf(num, den) is not efficient in that case because I would have to expand out the denominator. I already know the zeros and poles of my transfer function so would there be an easier way to implement H(jw)? Thanks.
  2. jcsd
  3. Sep 25, 2012 #2
    I've had to do this without the tf toolbox before. Why can't you just plot the magnitude and phase of the function with a frequency variable f = 0:1:100000 or whatever range you're interested in, where s = f*i*2*pi?
  4. Sep 25, 2012 #3
    I don't have Matlab with me at the moment, but there should be a 'Butter' function which takes the cut-off frequency and order as inputs and returns the numerator and denominator of the transfer function.
    There should also be a tf function which accepts the poles and zeros as inputs, instead of the num and den polynomials (or at least a polynomial function that returns the coefficients given its zeros; the inverse of 'roots')
    And if all those functions wouldn't be available in your Matlab version, you could still calculate the polynomial coefficients yourself with convolutions.

    Edit: the polynomial function is 'poly(vector_containing_roots)'

    Edit2: sys=zpk(zeros,poles,k), where k is a multiplicative constant.

    Edit3: or even simpler, I always forget this simple and elegant solution (I don't know if there's a version requirement):
    s=tf('s'); %from now on you can use s as the Laplace variable in expressions! (Also possible zo use 'z' for discrete-time systems)
    H=1/(s + w_c)^3;
    Last edited: Sep 25, 2012
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook