Matlab: Butterworth Filter Bode Plot

Click For Summary
SUMMARY

This discussion focuses on implementing nth order lowpass Butterworth filters in MATLAB for Bode plot visualization. The transfer function is defined as H(jw) = 1/(s + w_c)^n. Users can utilize the 'tf' function for transfer functions, but an efficient alternative is to use the 'zpk' function with known zeros and poles. The 'Butter' function can also generate the numerator and denominator based on the filter's cut-off frequency and order. Additionally, the 'poly' function can compute polynomial coefficients from roots, and the 'bode' function can directly plot the frequency response.

PREREQUISITES
  • Familiarity with MATLAB syntax and functions
  • Understanding of transfer functions and Bode plots
  • Knowledge of Butterworth filter design principles
  • Experience with zeros and poles in control systems
NEXT STEPS
  • Explore the 'Butter' function in MATLAB for generating Butterworth filter coefficients
  • Learn how to use the 'zpk' function for defining transfer functions with zeros and poles
  • Study the 'poly' function to convert roots into polynomial coefficients
  • Investigate the 'bode' function for plotting frequency response in MATLAB
USEFUL FOR

Electrical engineers, control system designers, and MATLAB users interested in filter design and frequency response analysis.

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
5K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
Replies
1
Views
5K