Difference between revisions of "Bode Plots"

From PrattWiki
Jump to navigation Jump to search
(Created page with "== Introduction == This is a '''''very''''' drafty page on Bode Plots. Currently, it focuses on the Maple code needed to create Bode Plots for magnitude and phase plots. ==...")
 
 
(3 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
== Maple Bode Plots ==
 
== Maple Bode Plots ==
 
Maple expects continuous transfer functions to be functions of <code>s</code>.   
 
Maple expects continuous transfer functions to be functions of <code>s</code>.   
 +
== Maple Cloud ==
 +
The work below is also in a worksheet on the Maple Cloud: [https://maple.cloud/app/6586100329086976/BodePlotsIntro?key=583699828AD343AD8D995850BCF4FB8DF6B5ABD12A5142E4B2B8711D6F62E0C0 BodePlotsDemo.mw]
 
=== Basics ===
 
=== Basics ===
 
Here is the process for generating the basic Bode magnitude and phase plots for a transfer function:
 
Here is the process for generating the basic Bode magnitude and phase plots for a transfer function:
Line 16: Line 18:
 
* If you would like to see both the actual Bode plots and the straight-line approximations, if you have Maple 2022 or later, you can use the <code>form</code> option to select exact, straight, or both: <syntaxhighlight>BodePlot(H1, form=both)</syntaxhighlight>
 
* If you would like to see both the actual Bode plots and the straight-line approximations, if you have Maple 2022 or later, you can use the <code>form</code> option to select exact, straight, or both: <syntaxhighlight>BodePlot(H1, form=both)</syntaxhighlight>
 
* If you want to change the frequency range, you can use <code>range=low..high</code>: <syntaxhighlight>BodePlot(H1, range=1..100)</syntaxhighlight>
 
* If you want to change the frequency range, you can use <code>range=low..high</code>: <syntaxhighlight>BodePlot(H1, range=1..100)</syntaxhighlight>
 +
* You can also make changes to the color, line style, and line thickness, as well as the size of each plot:<<syntaxhighlight>BodePlot(H1, color = gold, linestyle = longdash, thickness = 2, size=[400, 300]);
 +
</syntaxhighlight>See the references below for more information about those options. 
 +
* Note that you can add a title, but it will add the title to both plots.  It may make more sense to add a legend, even to a single transfer function's Bode plots - the legend can either be a string or a variable; if it is a variable, Maple will typeset it for you (subscripts are created with dunders):<syntaxhighlight>BodePlot(H1, legend = H__1)</syntaxhighlight>
 +
 
=== Multiple Bode Plots ===
 
=== Multiple Bode Plots ===
 
If you want to compare two or more Bode plots on a single graph, you will need to put the function versions (not the TransferFunction versions) in a ''matrix'' and then use the NewSystem command to make a system containing all the transfer functions.  For example, to get a single set of Bode plots with:<center><math>\begin{align*}H_1&=\frac{100}{s+100} & H_2&=\frac{s}{s+100}\end{align*}</math></center> you can use the following code:<syntaxhighlight>restart;
 
If you want to compare two or more Bode plots on a single graph, you will need to put the function versions (not the TransferFunction versions) in a ''matrix'' and then use the NewSystem command to make a system containing all the transfer functions.  For example, to get a single set of Bode plots with:<center><math>\begin{align*}H_1&=\frac{100}{s+100} & H_2&=\frac{s}{s+100}\end{align*}</math></center> you can use the following code:<syntaxhighlight>restart;
Line 26: Line 32:
 
BodePlot(Hs);</syntaxhighlight>
 
BodePlot(Hs);</syntaxhighlight>
  
If you want to add a legend and/or change the line colors and styles, you can do that with additional options:<syntaxhighlight>BodePlot(Hs, legend = ["Low-pass", "High-pass"], color = [turquoise, sienna], linestyle = [dash, dashdot], thickness = [3, 1], numpoints = 1000);</syntaxhighlight>
+
If you want to add a legend and/or change the line colors and styles, you can do that with additional options:<syntaxhighlight>BodePlot(Hs, legend = ["Low-pass", "High-pass"], color = [turquoise, sienna], linestyle = [dash, dashdot], thickness = [3, 1], numpoints = 1000, size=[400, 300]);</syntaxhighlight>See the references below for more information about those options.
  
 
== References ==
 
== References ==

Latest revision as of 18:44, 18 March 2024

Introduction

This is a very drafty page on Bode Plots. Currently, it focuses on the Maple code needed to create Bode Plots for magnitude and phase plots.

Maple Bode Plots

Maple expects continuous transfer functions to be functions of s.

Maple Cloud

The work below is also in a worksheet on the Maple Cloud: BodePlotsDemo.mw

Basics

Here is the process for generating the basic Bode magnitude and phase plots for a transfer function:

  • Initialize the workspace
    restart
  • Load DynamicSystems package to get TransferFunction and BodePlots commands
    with(DynamicSystems)
  • Load Optimization package to get Maximize command
    with(Optimization)
  • Create a function for the transfer function:
    H1r := 1000*s/((s + 1)*(s + 1000))
  • Create the actual transfer function:
    H1 := TransferFunction(H1r)
  • Make the Bode plots:
    BodePlot(H1)

Additional Options

  • If you would like to change the number of points used to make the plot (say, if the plot looks blocky), you can use the numpoints option:
    BodePlot(H1, numpoints=1000)
  • If you would like to see both the actual Bode plots and the straight-line approximations, if you have Maple 2022 or later, you can use the form option to select exact, straight, or both:
    BodePlot(H1, form=both)
  • If you want to change the frequency range, you can use range=low..high:
    BodePlot(H1, range=1..100)
  • You can also make changes to the color, line style, and line thickness, as well as the size of each plot:<
    BodePlot(H1, color = gold, linestyle = longdash, thickness = 2, size=[400, 300]);
    See the references below for more information about those options.
  • Note that you can add a title, but it will add the title to both plots. It may make more sense to add a legend, even to a single transfer function's Bode plots - the legend can either be a string or a variable; if it is a variable, Maple will typeset it for you (subscripts are created with dunders):
    BodePlot(H1, legend = H__1)

Multiple Bode Plots

If you want to compare two or more Bode plots on a single graph, you will need to put the function versions (not the TransferFunction versions) in a matrix and then use the NewSystem command to make a system containing all the transfer functions. For example, to get a single set of Bode plots with:

\(\begin{align*}H_1&=\frac{100}{s+100} & H_2&=\frac{s}{s+100}\end{align*}\)

you can use the following code:

restart;
with(DynamicSystems);
with(Optimization);
H1r := 100/(s + 100);
H2r := s/(s + 100);
H := <<H1r | H2r>>;
Hs := NewSystem(H);
BodePlot(Hs);

If you want to add a legend and/or change the line colors and styles, you can do that with additional options:

BodePlot(Hs, legend = ["Low-pass", "High-pass"], color = [turquoise, sienna], linestyle = [dash, dashdot], thickness = [3, 1], numpoints = 1000, size=[400, 300]);

See the references below for more information about those options.

References