Documentation Center

  • Trials
  • Product Updates


Plot Bode frequency response with additional plot customization options


h = bodeplot(sys)
bodeplot(..., plotoptions)


h = bodeplot(sys) plot the Bode magnitude and phase of the dynamic system model sys and returns the plot handle h to the plot. You can use this handle to customize the plot with the getoptions and setoptions commands.

bodeplot(sys) draws the Bode plot of the model sys. The frequency range and number of points are chosen automatically.

bodeplot(sys1,sys2,...) graphs the Bode response of multiple models sys1,sys2,... on a single plot. You can specify a color, line style, and marker for each model, as in


bodeplot(AX,...) plots into the axes with handle AX.

bodeplot(..., plotoptions) plots the Bode response with the options specified in plotoptions. Type

help bodeoptions 

for a list of available plot options. See Example 2 for an example of phase matching using the PhaseMatchingFreq and PhaseMatchingValue options.

bodeplot(sys,w) draws the Bode plot for frequencies specified by w. When w = {wmin,wmax}, the Bode plot is drawn for frequencies between wmin and wmax (in rad/TimeUnit, where TimeUnit is the time units of the input dynamic system, specified in the TimeUnit property of sys.). When w is a user-supplied vector w of frequencies, in rad/TimeUnit, the Bode response is drawn for the specified frequencies.

See logspace to generate logarithmically spaced frequency vectors.


Example 1

Use the plot handle to change options in a Bode plot.

sys = rss(5);
h = bodeplot(sys);
% Change units to Hz and make phase plot invisible

Example 2

The properties PhaseMatchingFreq and PhaseMatchingValue are parameters you can use to specify the phase at a specified frequency. For example, enter the following commands.

sys = tf(1,[1 1]); 
h = bodeplot(sys) % This displays a Bode plot.

Use this code to match a phase of 750 degrees to 1 rad/s.

p = getoptions(h); 
p.PhaseMatching = 'on'; 
p.PhaseMatchingFreq = 1; 
p.PhaseMatchingValue = 750; % Set the phase to 750 degrees at 1 
                            % rad/s.
setoptions(h,p); % Update the Bode plot.

The first bode plot has a phase of -45 degrees at a frequency of 1 rad/s. Setting the phase matching options so that at 1 rad/s the phase is near 750 degrees yields the second Bode plot. Note that, however, the phase can only be -45 + N*360, where N is an integer, and so the plot is set to the nearest allowable phase, namely 675 degrees (or 2*360 - 45 = 675).

Example 3

Compare the frequency responses of identified state-space models of order 2 and 6 along with their 2 std confidence regions.

load iddata1


w = linspace(8,10*pi,256);
h = bodeplot(sys1,sys2,w);
setoptions(h, 'PhaseMatching', 'on', 'ConfidenceRegionNumberSD', 2);

Use the context menu by right-clicking Characteristics > Confidence Region to turn on the confidence region characteristic.

Example 4

Compare the frequency response of a parametric model, identified from input/output data, to a nonparametric model identified using the same data.

  1. Identify parametric and non-parametric models based on data.

    load iddata2 z2;
    w = linspace(0,10*pi,128);
    sys_np = spa(z2,[],w);
    sys_p = tfest(z2,2);

    spa and tfest require System Identification Toolbox™ software. sys_np is a non-parametric identified model. sys_p is a parametric identified model.

  2. Create a Bode plot that includes both systems.

    opt = bodeoptions;  opt.PhaseMatching = 'on';
    bodeplot(sys_np,sys_p,w, opt);

More About

expand all



See Also

| | | |

Was this topic helpful?