Matlab: Butterworth Filter Bode Plot

In summary, the conversation discusses how to plot different order Butterworth filters using MATLAB. The speaker is struggling to input their transfer function and is looking for a more efficient way to do so. Suggestions are made to use the 'Butter' and 'tf' functions, as well as calculating the polynomial coefficients manually. The speaker also mentions a simpler solution of using the 'bode' function with the Laplace variable 's'.
  • #1
hadroneater
59
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
  • #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?
 
  • #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;
bode(H);
 
Last edited:

1. What is a Butterworth filter?

A Butterworth filter is a type of filter used in signal processing to remove unwanted frequencies from a signal. It is named after the British engineer and physicist Stephen Butterworth, who first described it in the 1930s.

2. How does a Butterworth filter work?

A Butterworth filter works by attenuating frequencies above a certain cutoff frequency while allowing lower frequencies to pass through. This is achieved by using a specific type of transfer function that has a gradual slope in the frequency domain, resulting in a smooth transition between the passband and stopband.

3. How can I design a Butterworth filter using Matlab?

To design a Butterworth filter using Matlab, you can use the "butter" function, which takes in the desired filter order and cutoff frequency as parameters. This function will return the filter coefficients that can then be used in the "filter" function to filter a signal.

4. How do I plot the frequency response of a Butterworth filter in Matlab?

You can use the "freqz" function in Matlab to plot the frequency response of a Butterworth filter. This function takes in the filter coefficients as well as the desired number of frequency points and will return the magnitude and phase response of the filter, which can then be plotted using the "plot" function.

5. Can I customize the Bode plot of a Butterworth filter in Matlab?

Yes, you can customize the Bode plot of a Butterworth filter in Matlab by changing the frequency range, adding grid lines, and labeling the axes. You can also plot multiple filters on the same graph to compare their frequency responses. Matlab also allows you to export the Bode plot as an image or save it as a figure for future use.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
934
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
782
Back
Top