Bode Plot Matlab Homework: High Pass Filter

Click For Summary

Discussion Overview

The discussion revolves around creating a theoretical Bode plot for a high-pass filter using MATLAB. Participants explore the correct formulation of the transfer function and the appropriate MATLAB commands to generate the desired plot.

Discussion Character

  • Homework-related
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant presents a transfer function for a high-pass filter and shares their MATLAB code, expressing confusion over the incorrect output of the Bode plot.
  • Another participant suggests using the Laplace transform variable 's' for clarity and provides an alternative formulation of the transfer function.
  • A third participant confirms that modifying the code as suggested yields the correct curve for the Bode plot, indicating a successful adjustment.
  • A later reply challenges the initial transfer function definition, stating that the numerator and denominator vectors must be defined correctly to achieve the desired transfer function form.

Areas of Agreement / Disagreement

Participants generally agree on the need to correctly define the transfer function in MATLAB, but there are differing views on the initial formulation and the necessary adjustments to the code.

Contextual Notes

Some limitations include potential misunderstandings in defining transfer functions and the specific requirements of MATLAB commands for generating Bode plots. The discussion does not resolve all aspects of the transfer function formulation.

Who May Find This Useful

This discussion may be useful for students or practitioners working with Bode plots in MATLAB, particularly those dealing with high-pass filter designs and transfer function representations.

roam
Messages
1,265
Reaction score
12

Homework Statement



I'm trying to make a theoretical Bode plot of a High pass filter (made up of a capacitor and a resistor). The transfer function is:

##T=\frac{V_{out}}{V_{in}}= \frac{R}{R+1/(j\omega C)} = \frac{1}{1-j\omega_0 / \omega}##

With a corner frequency of 5 kHz or in radians:

##\omega_0 = \frac{1}{RC} = \frac{1}{(1440.96 \Omega)(22 \ nF)}##

The Attempt at a Solution



I rewrote the transfer function as:

##\frac{s}{s+\omega_0}## where s=jω

And used the following code:

w=1/(1440.96*(22e-9))

N=[1];
D=[1 w];
sys = rss(5);
h = bodeplot(sys);
setoptions(h,'FreqUnits','Hz','PhaseVisible','off');
h=bode(N,D);

And here is what I got:

qrdjc7.jpg


Clearly this is wrong, it is not the graph of a high-pass filter. Here is my experimental result (how the curve should look like):

iqg9vp.jpg


So what is wrong with my code? :confused:

Any help is greatly appreciated.
 

Attachments

  • theoretical.jpg
    theoretical.jpg
    10.5 KB · Views: 585
  • experimental.jpg
    experimental.jpg
    13.2 KB · Views: 540
Physics news on Phys.org
MATLAB usually expects that when you're working with transfer functions, they're expressed in the complex variable of the Laplace transform. You can make things easier for yourself if you instead use:
<br /> \frac{V_\mathrm{out}}{V_\mathrm{in}} = \frac{R}{R + \frac{1}{s C}}<br />
Both commands 'bodeplot' and 'bode' expect an argument of 'Dynamic System Model' type. Here's a trick you can use to make your code more readable when creating these objects:
Code:
s = tf('s');
sys = R/(R + 1/(s*C));

Maybe give that a try.
 
  • Like
Likes   Reactions: 1 person
Thank you so much for the prompt reply. I modified my code as you instructed, and the resulting curve looks correct (I get the 5kHz corner frequency where required). :)
 
I'm late to the party, but the problem is you've defined the transfer function incorrectly.
Code:
N=[1];
D=[1 w];
will produce\frac{1}{s+\omega_0};to get the desired TF of\frac{s}{s+\omega_0}you need to do
Code:
N=[1 0];
D=[1 w];

The vectors defining the numerator and denominator of the TF are descending powers of s, so you need [s^1\;s^0].
 
  • Like
Likes   Reactions: 1 person

Similar threads

  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K