MATLAB Matlab: Butterworth Filter Bode Plot

Click For Summary
To plot nth order lowpass Butterworth filters in MATLAB, the transfer function can be expressed as H(jw) = 1/(s + w_c)^n. Instead of using the tf(num, den) function, which requires expanding the denominator, users can utilize the 'Butter' function to obtain the numerator and denominator directly from the cutoff frequency and order. Alternatively, the zpk function can be employed with zeros, poles, and a gain constant to define the system. For a more straightforward approach, defining the Laplace variable with s=tf('s') allows for direct manipulation of the transfer function. This method simplifies the process of plotting the Bode plot for the desired filter orders.
hadroneater
Messages
56
Reaction score
0
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.
 
Physics news on Phys.org
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?
 
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;
bode(H);
 
Last edited:

Similar threads

Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
Replies
1
Views
4K