Products & Services Industries Academia Support User Community Company

Learn more about Control System Toolbox   

bode - Bode diagram of frequency response

Syntax

bode
bode(sys)
bode(sys,w)
bode(sys1,sys2,...,sysN)
bode(sys1,sys2,...,sysN,w)
bode(sys1,'PlotStyle1',...,sysN,'PlotStyleN')

Description

bode computes the magnitude and phase of the frequency response of LTI models. When you invoke this function without left-side arguments, bode produces a Bode plot on the screen. The magnitude is plotted in decibels (dB), and the phase in degrees. The decibel calculation for mag is computed as 20log10 , where is the system's frequency response. You can use bode plots to analyze system properties such as the gain margin, phase margin, DC gain, bandwidth, disturbance rejection, and stability.

bode(sys) plots the Bode response of an arbitrary LTI model sys. This model can be continuous or discrete, and SISO or MIMO. In the MIMO case, bode produces an array of Bode plots, each plot showing the Bode response of one particular I/O channel. The frequency range is determined automatically based on the system poles and zeros.

bode(sys,w) explicitly specifies the frequency range or frequency points for the plot. To focus on a particular frequency interval [wmin,wmax], set w = {wmin,wmax}. To use particular frequency points, set w to the vector of desired frequencies. Use logspace to generate logarithmically spaced frequency vectors. Specify all frequencies in radians per second (rad/s).

bode(sys1,sys2,...,sysN) or bode(sys1,sys2,...,sysN,w) plots the Bode responses of several LTI models on a single figure. All systems must have the same number of inputs and outputs, but they can include both continuous and discrete systems. Use this syntax to compare the Bode responses of multiple systems.

bode(sys1,'PlotStyle1',...,sysN,'PlotStyleN') specifies the color, linestyle, and/or marker for each system's plot. For example:

bode(sys1,'r--',sys2,'gx')

produces a red dashed lines for the first system sys1 and green 'x' markers for the second system sys2.

When you invoke this function with left-side arguments, the commands

[mag,phase,w] = bode(sys)
[mag,phase] = bode(sys,w)

return the magnitude and phase (in degrees) of the frequency response at the frequencies w (in rad/s). The outputs mag and phase are 3-D arrays with the frequency as the last dimension (see "Arguments" for details). To convert the magnitude to decibels, type

magdb = 20*log10(mag)

Remarks

If sys is an FRD model, bode(sys,w), w can only include frequencies in sys.frequency.

You can change the properties of your plot, for example the units. For information on the ways to change properties of your plots, see Ways to Customize Plots.

Arguments

The output arguments mag and phase are 3-D arrays with dimensions

For SISO systems, mag(1,1,k) and phase(1,1,k) give the magnitude and phase of the response at the frequency  = w(k).

MIMO systems are treated as arrays of SISO systems and the magnitudes and phases are computed for each SISO entry hij independently (hij is the transfer function from input j to output i). The values mag(i,j,k) and phase(i,j,k) then characterize the response of hij at the frequency w(k).

Example

You can plot the Bode response of the continuous SISO system

by typing

g = tf([1 0.1 7.5],[1 0.12 9 0 0]);
bode(g)

To plot the response on a wider frequency range, for example, from 0.1 to 100 rad/s, type

bode(g,{0.1 , 100})

You can also discretize this system using zero-order hold and the sample time second, and compare the continuous and discretized responses by typing

gd = c2d(g,0.5)
bode(g,'r',gd,'b--')

Algorithm

The bode command computes the ZPK representation of the model and evaluates the gain and phase of the frequency response from the zero, pole, gain data for each I/O pair.

For continuous-time models, the bode command evaluates the frequency response on the imaginary axis and only considers positive frequencies.

For discrete-time models, the bode command evaluates the frequency response on the unit circle. To facilitate interpretation, the command parameterizes the upper half of the unit circle as

where Ts is the sample time. is called the Nyquist frequency. The equivalent "continuous-time frequency"  is then used as the x-axis variable. Because is periodic with period 2 , the bode command plots the response only up to the Nyquist frequency . If you do not specify a sample time, this value defaults to Ts = 1.

Diagnostics

If the system has a pole on the axis (or unit circle in the discrete case) and w contains this frequency point, the gain is infinite and bode produces a warning message.

See Also

bodeoptions, evalfr, freqresp, ltiview, nichols, nyquist, sigma

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS