Bode Plot Matlab Homework: High Pass Filter

In summary, the conversation was about creating a theoretical Bode plot for a High pass filter using a transfer function with a corner frequency of 5 kHz. The attempt at a solution involved rewriting the transfer function and using a specific code to plot the graph. However, the resulting curve was incorrect, and it was suggested to modify the code and use a different transfer function definition. The correct code produced the desired curve with the 5 kHz corner frequency.
  • #1
roam
1,271
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: 501
  • experimental.jpg
    experimental.jpg
    13.2 KB · Views: 461
Physics news on Phys.org
  • #2
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:
[tex]
\frac{V_\mathrm{out}}{V_\mathrm{in}} = \frac{R}{R + \frac{1}{s C}}
[/tex]
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 1 person
  • #3
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). :)
 
  • #4
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[tex]\frac{1}{s+\omega_0};[/tex]to get the desired TF of[tex]\frac{s}{s+\omega_0}[/tex]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 [itex]s[/itex], so you need [itex][s^1\;s^0][/itex].
 
  • Like
Likes 1 person
  • #5




Based on your transfer function and corner frequency, it looks like your code is correct. However, there are a few things to note. First, make sure you are using the correct units for your frequency (Hz or rad/s). Also, check to see if there are any typos in your code or if you are missing any necessary functions. Additionally, it could be helpful to plot the magnitude and phase separately to see if there are any discrepancies. Finally, make sure your experimental result is accurate and matches the expected response for a high-pass filter. If you are still having trouble, try reaching out to a classmate or your instructor for further assistance.
 

What is a Bode plot?

A Bode plot is a graphical representation of a system's frequency response, showing the magnitude and phase of the system's output as a function of frequency. It is commonly used in control systems and signal processing to analyze the behavior of filters and amplifiers.

How do I create a Bode plot in Matlab?

To create a Bode plot in Matlab, you can use the bode function. This function takes in the transfer function of your system as an input and plots the magnitude and phase response of the system.

What is a high pass filter?

A high pass filter is an electronic circuit that allows high-frequency signals to pass through while attenuating low-frequency signals. It is commonly used to remove unwanted low-frequency noise from a signal.

How do I design a high pass filter in Matlab?

You can design a high pass filter in Matlab using the designfilt function. This function allows you to specify the type of filter (e.g. Butterworth, Chebyshev, etc.), the cutoff frequency, and other parameters to design your filter.

How can I analyze the performance of my high pass filter using a Bode plot?

You can analyze the performance of your high pass filter using a Bode plot by looking at the magnitude and phase response. The cutoff frequency, which is where the magnitude response drops by 3dB, can give you an idea of the filter's effectiveness in removing low-frequency signals. The phase response also tells you how the filter affects the phase of the signal at different frequencies.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
16
Views
955
  • Engineering and Comp Sci Homework Help
Replies
8
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top