Magnitude-only Bode plot of frequency response

collapse all in page

## Syntax

`bodemag(sys)`

`bodemag(sys1,sys2,...,sysN)`

`bodemag(sys1,LineSpec1,...,sysN,LineSpecN)`

`bodemag(___,w)`

## Description

`bodemag`

enables you to generate magnitude-only plots to visualize the magnitude frequency response of a dynamic system.

For a more comprehensive function, see bode. `bode`

provides magnitude and phase information. If you have System Identification™ toolbox, `bode`

also returns the computed values, including statistical estimates.

For more customizable plotting options, see bodeplot.

`bodemag(sys)`

creates a Bode magnitude plot of the frequency response of the dynamic system model `sys`

. The plot displays the magnitude (in dB) of the system response as a function of frequency. `bodemag`

automatically determines frequencies to plot based on system dynamics.

If `sys`

is a multi-input, multi-output (MIMO) model, then `bodemag`

produces an array of Bode magnitude plots in which each plot shows the frequency response of one I/O pair.

If `sys`

is a model with complex coefficients, then in:

Log frequency scale, the plot shows two branches, one for positive frequencies and one for negative frequencies. The plot also shows arrows to indicate the direction of increasing frequency values for each branch. See Bode Plot of Model with Complex Coefficients.

Linear frequency scale, the plot shows a single branch with a symmetric frequency range centered at a frequency value of zero.

example

`bodemag(sys1,sys2,...,sysN)`

plots the frequency response of multiple dynamic systems on the same plot. All systems must have the same number of inputs and outputs.

example

`bodemag(sys1,LineSpec1,...,sysN,LineSpecN)`

specifies a color, line style, and marker for each system in the plot.

example

`bodemag(___,w)`

plots system responses for frequencies specified by `w`

. You can specify a frequency range or a vector of frequencies. You can use this syntax with any of the input-argument combinations in previous syntaxes.

example

## Examples

collapse all

### Bode Magnitude Plot of Dynamic System

This example uses:

- Control System ToolboxControl System Toolbox

Open Live Script

Create a Bode magnitude plot of the following continuous-time SISO dynamic system.

$$\mathit{H}\left(\mathit{s}\right)=\frac{{\mathit{s}}_{}^{2}+0.1\mathit{s}+7.5}{{\mathit{s}}_{}^{4}+0.12{\mathit{s}}_{}^{3}+9{\mathit{s}}_{}^{2}}$$

H = tf([1 0.1 7.5],[1 0.12 9 0 0]);bodemag(H)

`bodemag`

automatically selects the plot range based on the system dynamics.

### Bode Magnitude Plot at Specified Frequencies

This example uses:

- Control System ToolboxControl System Toolbox

Open Live Script

Create a Bode magnitude plot over a specified frequency range. Use this approach when you want to focus on the dynamics in a particular range of frequencies.

`H = tf([-0.1,-2.4,-181,-1950],[1,3.3,990,2600]);bodemag(H,{1,100})grid on`

The cell array `{1,100}`

specifies the minimum and maximum frequency values in the Bode magnitude plot. When you provide frequency bounds in this way, the function selects intermediate points for frequency response data.

Alternatively, specify a vector of frequency points to use for evaluating and plotting the frequency response.

w = [1 5 10 15 20 23 31 40 44 50 85 100];bodemag(H,w,'.-')grid on

`bodemag`

plots the frequency response at the specified frequencies only.

### Compare Bode Magnitude Plots of Several Dynamic Systems

This example uses:

- Control System ToolboxControl System Toolbox

Open Live Script

Compare the magnitude of the frequency response of a continuous-time system to an equivalent discretized system on the same Bode plot.

Create continuous-time and discrete-time dynamic systems.

`H = tf([1 0.1 7.5],[1 0.12 9 0 0]);Hd = c2d(H,0.5,'zoh');`

Create a Bode magnitude plot that displays the responses of both systems.

bodemag(H,Hd)

The Bode magnitude plot of a discrete-time system includes a vertical line marking the Nyquist frequency of the system.

### Bode Magnitude Plot with Specified Line and Marker Attributes

This example uses:

- Control System ToolboxControl System Toolbox

Open Live Script

Specify the color, linestyle, or marker for each system in a Bode magnitude plot using the `LineSpec`

input arguments.

H = tf([1 0.1 7.5],[1 0.12 9 0 0]);Hd = c2d(H,0.5,'zoh');bodemag(H,'r',Hd,'b--')

The first `LineSpec`

argument `'r'`

specifies a solid red line for the response of `H`

. The second `LineSpec`

argument `'b--'`

specifies a dashed blue line for the response of `Hd`

.

### Magnitude of MIMO System

This example uses:

- Control System ToolboxControl System Toolbox

Open Live Script

For this example, create a 2-output, 3-input system.

rng(0,'twister'); % For reproducibilityH = rss(4,2,3);

For this system, `bodemag`

plots the magnitude-only frequency responses of each I/O channel in a separate plot in a single figure.

bodemag(H)

## Input Arguments

collapse all

`sys`

— Dynamic system

dynamic system model | model array

Dynamic system, specified as a SISO or MIMO dynamic system model or array of dynamic system models. Dynamic systems that you can use include:

Continuous-time or discrete-time numeric LTI models, such as tf (Control System Toolbox), zpk (Control System Toolbox), or ss (Control System Toolbox) models.

Sparse state-space models, such as sparss (Control System Toolbox) or mechss (Control System Toolbox) models.

Generalized or uncertain LTI models such as genss (Control System Toolbox) or uss (Robust Control Toolbox) models. Using uncertain models requires Robust Control Toolbox™ software.

For tunable control design blocks, the function evaluates the model at its current value to plot the response.

For uncertain control design blocks, the function plots the nominal value and random samples of the model.

Identified LTI models, such as idtf, idss, or idproc models.

If `sys`

is an array of models, the plot shows responses of all models in the array on the same axes.

`LineSpec`

— Line style, marker, and color

string | character vector

Line style, marker, and color, specified as a string or character vector containing symbols. The symbols can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line.

**Example: **`'--or'`

is a red dashed line with circle markers

Line Style | Description |
---|---|

`"-"` | Solid line |

`"--"` | Dashed line |

`":"` | Dotted line |

`"-."` | Dash-dotted line |

Marker | Description |
---|---|

`"o"` | Circle |

`"+"` | Plus sign |

`"*"` | Asterisk |

`"."` | Point |

`"x"` | Cross |

`"_"` | Horizontal line |

`"|"` | Vertical line |

`"s"` | Square |

`"d"` | Diamond |

`"^"` | Upward-pointing triangle |

`"v"` | Downward-pointing triangle |

`">"` | Right-pointing triangle |

`"<"` | Left-pointing triangle |

`"p"` | Pentagram |

`"h"` | Hexagram |

Color | Description |
---|---|

`"r"` | red |

`"g"` | green |

`"b"` | blue |

`"c"` | cyan |

`"m"` | magenta |

`"y"` | yellow |

`"k"` | black |

`"w"` | white |

`w`

— Frequencies

`{wmin,wmax}`

| vector | `[]`

Frequencies at which to compute the response, specified as one of the following:

Cell array of the form

`{wmin,wmax}`

— Compute the response at frequencies in the range from`wmin`

to`wmax`

. If`wmax`

is greater than the Nyquist frequency of sys, the response is computed only up to the Nyquist frequency.Vector of frequencies — Compute the response at each specified frequency. For example, use logspace to generate a row vector with logarithmically spaced frequency values. The vector

`w`

can contain both positive and negative frequencies.`[]`

— Automatically select frequencies based on system dynamics.

For models with complex coefficients, if you specify a frequency range of [*w*_{min},*w*_{max}] for your plot, then in:

Log frequency scale, the plot frequency limits are set to [

*w*_{min},*w*_{max}] and the plot shows two branches, one for positive frequencies [*w*_{min},*w*_{max}] and one for negative frequencies [–*w*_{max},–*w*_{min}].Linear frequency scale, the plot frequency limits are set to [–

*w*_{max},*w*_{max}] and the plot shows a single branch with a symmetric frequency range centered at a frequency value of zero.

Specify frequencies in units of rad/`TimeUnit`

, where `TimeUnit`

is the `TimeUnit`

property of the model.

## Algorithms

The software computes the frequency response as follows:

Compute the zero-pole-gain (zpk (Control System Toolbox)) representation of the dynamic system.

Evaluate the gain and phase of the frequency response based on the zero, pole, and gain data for each input/output channel of the system.

For continuous-time systems,

`bode`

evaluates the frequency response on the imaginary axis*s*=*jω*and considers only positive frequencies.For discrete-time systems,

`bode`

evaluates the frequency response on the unit circle. To facilitate interpretation, the command parameterizes the upper half of the unit circle as:$$z={e}^{j\omega {T}_{s}},\text{\hspace{1em}}0\le \omega \le {\omega}_{N}=\frac{\pi}{{T}_{s}},$$

where

*T*is the sample time and_{s}*ω*is the Nyquist frequency. The equivalent continuous-time frequency_{N}*ω*is then used as the*x*-axis variable. Because $$H\left({e}^{j\omega {T}_{s}}\right)$$ is periodic with period 2*ω*,_{N}`bode`

plots the response only up to the Nyquist frequency*ω*. If sys is a discrete-time model with unspecified sample time,_{N}`bode`

uses*T*= 1._{s}

## Alternative Functionality

You can also create a magnitude-only frequency response using bodeplot. To do so, set the `PhaseVisible`

property of the `bodeplot`

object to `"off"`

.

`bp = bodeplot(sys);bp.PhaseVisible = "off";`

## Version History

**Introduced in R2012a**

## See Also

bode | bodeplot | freqresp | nyquist | spectrum | step

### Topics

- Plot Bode and Nyquist Plots at the Command Line
- Dynamic System Models

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français

- United Kingdom (English)

Contact your local office