Bode Plots

From PrattWiki
Revision as of 17:02, 18 March 2024 by DukeEgr93 (talk | contribs) (Multiple Bode Plots)
Jump to navigation Jump to search

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.

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