Bode plot of frequency response, magnitude and phase of frequency response
bode(sys)
bode(sys1,...,sysN)
bode(sys1,PlotStyle1,...,sysN,PlotStyleN)
bode(...,w)
[mag,phase]
= bode(sys,w)
[mag,phase,wout]
= bode(sys)
[mag,phase,wout,sdmag,sdphase]
= bode(sys)
bode(
creates
a Bode plot of the frequency response of a dynamic
system model sys
)sys
. The plot displays
the magnitude (in dB) and phase (in degrees) of the system response
as a function of frequency.
When sys
is a multiinput, multioutput
(MIMO) model, bode
produces an array of Bode plots,
each plot showing the frequency response of one I/O pair.
bode
automatically determines the plot
frequency range based on system dynamics.
bode(
plots
the frequency response of multiple dynamic systems in a single figure.
All systems must have the same number of inputs and outputs.sys
1,...,sys
N)
bode(
plots
system responses using the color, linestyle, and markers specified
by the sys
1,PlotStyle
1,...,sys
N,PlotStyle
N)PlotStyle
strings.
bode(...,
plots
system responses at frequencies determined by w
)w
.
If w
is a cell array {wmin,wmax}
, bode(sys,w)
plots
the system response at frequency values in the range {wmin,wmax}
.
If w
is a vector of frequencies, bode(sys,w)
plots
the system response at each of the frequencies specified in w
.
[
returns magnitudes mag
,phase
]
= bode(sys,w
)mag
in
absolute units and phase values phase
in degrees.
The response values in mag
and phase
correspond
to the frequencies specified by w
as follows:
If w
is a cell array {wmin,wmax}
, [mag,phase] = bode(sys,w)
returns the system
response at frequency values in the range {wmin,wmax}
.
If w
is a vector of frequencies, [mag,phase] = bode(sys,w)
returns the system
response at each of the frequencies specified in w
.
[
returns magnitudes, phase
values, and frequency values mag
,phase
,wout
]
= bode(sys
)wout
corresponding
to bode(sys)
.
[
additionally returns the
estimated standard deviation of the magnitude and phase values when mag
,phase
,wout
,sdmag
,sdphase
]
= bode(sys
)sys
is
an identified model and []
otherwise.

Dynamic system model, such as a Numeric LTI model, or an array of such models. 

Line style, marker, and color of both the line and marker, specified
as a one, two, or threepart string enclosed in single quotes For more information about configuring the 

Input frequency values, specified as a row vector or a twoelement cell array. Possible values of
Specify frequency values in radians per 

Bode magnitude of the system response in absolute units, returned as a 3D array with dimensions (number of outputs) × (number of inputs) × (number of frequency points).
You can convert the magnitude from absolute units to decibels using: magdb = 20*log10(mag) 

Phase of the system response in degrees, returned as a 3D array with dimensions are (number of outputs) × (number of inputs) × (number of frequency points).


Response frequencies, returned as a row vector of frequency
points. Frequency values are in radians per 

Estimated standard deviation of the magnitude. If 

Estimated standard deviation of the phase. If 
Create a Bode plot of the following continuoustime SISO dynamic system.
H = tf([1 0.1 7.5],[1 0.12 9 0 0]); bode(H)
bode
automatically selects the plot range based on the system dynamics.
Create a Bode 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([1 0.1 7.5],[1 0.12 9 0 0]); bode(H,{0.1,10})
The cell array {0.1,10}
specifies the minimum and maximum frequency values in the Bode plot. When you provide frequency bounds in this way, the software selects intermediate points for frequency response data.
Alternatively, specify a vector of frequency points to use for evaluating and plotting the frequency response.
w = logspace(1,1,100); bode(H,w)
logspace
defines a logarithmically spaced frequency vector in the range of 0.110 rad/s.
Compare the frequency response of a continuoustime system to an equivalent discretized system on the same Bode plot.
Create continuoustime and discretetime dynamic systems.
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
Hd = c2d(H,0.5,'zoh');
Create a Bode plot that displays both systems.
bode(H,Hd)
The Bode plot of a discretetime system includes a vertical line marking the Nyquist frequency of the system.
Specify the color, linestyle, or marker for each system in a Bode plot using the PlotStyle
input arguments.
H = tf([1 0.1 7.5],[1 0.12 9 0 0]); Hd = c2d(H,0.5,'zoh'); bode(H,'r',Hd,'b')
The string 'r'
specifies a solid red line for the response of H
. The string 'b'
specifies a dashed blue line for the response of Hd
.
Compute the magnitude and phase of the frequency response of a dynamic system.
H = tf([1 0.1 7.5],[1 0.12 9 0 0]); [mag phase wout] = bode(H);
Because H
is a SISO model, the first two
dimensions of mag
and phase
are
both 1. The third dimension is the number of frequencies in wout
.
Compare the frequency response of a parametric model, identified from input/output data, to a nonparametric model identified using the same data.
Identify parametric and nonparametric models based on data.
load iddata2 z2; w = linspace(0,10*pi,128); sys_np = spa(z2,[],w); sys_p = tfest(z2,2);
sys_np
is a nonparametric identified model. sys_p
is a parametric identified model.
Create a Bode plot that includes both systems.
bode(sys_np,sys_p,w); legend('sysnp','sysp')
Compute the standard deviation of the magnitude and phase of an identified model. Use this data to create a 3σ plot of the response uncertainty.
Identify a transfer function model based on data. Obtain the standard deviation data for the magnitude and phase of the frequency response.
load iddata2 z2; sys_p = tfest(z2,2); w = linspace(0,10*pi,128); [mag,ph,w,sdmag,sdphase] = bode(sys_p,w);
sys_p
is an identified transfer function model. sdmag
and sdphase
contain the standard deviation data for the magnitude and phase of the frequency response, respectively.
Use the standard deviation data to create a 3 plot corresponding to the confidence region.
mag = squeeze(mag); sdmag = squeeze(sdmag); semilogx(w,mag,'b',w,mag+3*sdmag,'k:',w,mag3*sdmag,'k:');
You can also rightclick the Bode plot and select Characteristics > Confidence Region or use the showConfidence
command to plot the confidence region.
Use bodeplot
when you need additional plot
customization options.