Documentation Center 
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(sys) creates a Bode plot of the frequency response of a dynamic system model 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(sys1,...,sysN) plots the frequency response of multiple dynamic systems in a single figure. All systems must have the same number of inputs and outputs.
bode(sys1,PlotStyle1,...,sysN,PlotStyleN) plots system responses using the color, linestyle, and markers specified by the PlotStyle strings.
bode(...,w) plots system responses at frequencies determined by 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.
[mag,phase] = bode(sys,w) returns magnitudes 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.
[mag,phase,wout] = bode(sys) returns magnitudes, phase values, and frequency values wout corresponding to bode(sys).
[mag,phase,wout,sdmag,sdphase] = bode(sys) additionally returns the estimated standard deviation of the magnitude and phase values when sys is an identified model and [] otherwise.
sys 
Dynamic system model, such as a Numeric LTI model, or an array of such models. 
PlotStyle 
Line style, marker, and color of both the line and marker, specified as a one, two, or threepart string enclosed in single quotes (' '). The elements of the string can appear in any order. The string can specify only the line style, the marker, or the color. For more information about configuring the PlotStyle string, see Specify Line Style, Color, and Markers in the MATLAB^{®} documentation. 
w 
Input frequency values, specified as a row vector or a twoelement cell array. Possible values of w:
Specify frequency values in radians per TimeUnit, where TimeUnit is the time units of the input dynamic system, specified in the TimeUnit property of sys. 
mag 
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 
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).

wout 
Response frequencies, returned as a row vector of frequency points. Frequency values are in radians per TimeUnit, where TimeUnit is the value of the TimeUnit property of sys. 
sdmag 
Estimated standard deviation of the magnitude. sdmag has the same dimensions as mag. If sys is not an identified LTI model, sdmag is []. 
sdphase 
Estimated standard deviation of the phase. sdphase has the same dimensions as phase. If sys is not an identified LTI model, sdphase is []. 
Bode Plot of Dynamic System
Create Bode plot of the dynamic system:
H(s) is a continuoustime SISO 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.
Bode Plot at Specified Frequencies
Create 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.
Alternatively, you can specify a vector of frequencies to use for evaluating and plotting the frequency response.
w = logspace(1,1,50); bode(H,w)
logspace defines a logarithmically spaced frequency vector in the range of 0.110 rad/s.
Compare Bode Plots of Several Dynamic Systems
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 Bode plot that includes both systems.
bode(H,Hd)
Bode Plot with Specified Line and Marker Attributes
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');
H and Hd are two different systems.
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.
Obtain Magnitude and Phase Data
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.
Bode Plot of Identified Model
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);
Obtain Magnitude and Phase Standard Deviation Data of Identified Model
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.
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:');