How to plot a bode graph for a filtered output?

4 views (last 30 days)
So I have a IIR butterworth filter with coeffficient converted into its transfer function, [b a]=sos2tf(SOS,G). I have a input audio file that I am using this filter on, and I did y = fitler(b,a,x), but now I am confused as to how I can plot the magnitude and frequency of this output?. I am also lacking theoritical knowledge on this subject which has made it hard for me to understand this.

Accepted Answer

Star Strider
Star Strider on 7 Dec 2021
... coeffficient converted into its transfer function, [b a]=sos2tf(SOS,G).
Do not do that! Keep it as a second-order-section realisation for best results and greatest stability.
y = fitler(b,a,x)
Do not do that, either. Use the filtfilt function instead, since its results are phase-neutral (no phase distortion).
Use the fft function to calculate the frequency-domain (spectrum) representation of the output. Plot the magnitude using the absolute (abs) value, and the phase using the angle function.
The documentation for those functions go into extensive detail as to how to use them, so I will not describe them further here.
.
  6 Comments
Utsang Dhungel
Utsang Dhungel on 8 Dec 2021
so if the frequency of my output were 44100, my case would be 44100/2, so fhz would go from 0: 44100/2, and then same process follows?
Star Strider
Star Strider on 8 Dec 2021
Yes, exactly.
To illustrate —
fHz = linspace(0, 44100/2, 11);
fHz(1:6)
ans = 1×6
0 2205 4410 6615 8820 11025
fHz(7:11)
ans = 1×5
13230 15435 17640 19845 22050
fradsec = (fHz * pi)/max(fHz);
fradsec(1:6)
ans = 1×6
0 0.3142 0.6283 0.9425 1.2566 1.5708
fradsec(7:11)
ans = 1×5
1.8850 2.1991 2.5133 2.8274 3.1416
.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!