Written and maintained by CASRAI Editorial Board
Published
On this page
Short answer: in MATLAB, define the system as a model object such as tf, then call bode(sys) for a quick plot or bodeplot(sys) when you need a chart object you can customise. Both belong to the Control System Toolbox. This guide walks through one task-ordered sequence, from transfer function to Bode plot to numeric data, and covers the two mistakes that catch most people: the returned magnitude is not in decibels, and the default frequency axis is rad/s, not Hz.
Who this is for: researchers, engineers and analysts who have a transfer function or state-space model and need a magnitude and phase plot they can read, export or reproduce in a script. Commands below follow the MathWorks documentation pages listed under Sources (read 2026-11-08).
What is a Bode plot and what is it used for in research?
A Bode plot shows the frequency response of a linear system as two stacked graphs: magnitude (conventionally in decibels) and phase (in degrees), both against frequency on a logarithmic axis. Researchers use it to see how a system amplifies or attenuates signals at different frequencies, and in control work to judge stability margins and bandwidth. For the wider field this belongs to, see what control theory and systems engineering research covers. A related frequency-domain method from electrochemistry is covered in impedance spectroscopy.
Install or access (official source only)
The bode and bodeplot functions are part of MathWorks’ Control System Toolbox, which runs inside MATLAB. Licensing and downloads come only from mathworks.com or your institution’s MathWorks account. Two related cases need an additional toolbox: identified models (idtf, idss and similar) require the System Identification Toolbox, and uncertain state-space models (uss) require the Robust Control Toolbox.
How do I create a Bode plot in MATLAB using a transfer function?
Define the transfer function with tf and pass it to bode. MATLAB chooses the frequency range automatically from the system dynamics.
- Create the model. Numerator and denominator are coefficient vectors in descending powers of s:
H = tf([1 0.1 7.5], [1 0.12 9 0 0]); - Plot it.
bode(H)opens a figure with magnitude on top and phase below. - Set your own frequency range. A cell array
{wmin, wmax}sets the span; add a grid for reading values:bode(H, {1, 100}); grid on - Plot at chosen frequencies. Pass a vector of frequencies and an optional line style:
w = [1 5 10 15 20 23 31 40 44 50 85 100];
bode(H, w, '.-'); grid on
If you want log-spaced points, see linspace in MATLAB for building evenly spaced vectors (uselogspacefor logarithmic spacing). - Overlay several systems. For example a continuous model and its discretised version:
Hd = c2d(H, 0.5, 'zoh');
bode(H, 'r', Hd, 'b--') - Get numbers instead of (or as well as) a figure. With output arguments,
bodereturns data; terminate with a semicolon to suppress the plot:[mag, phase, wout] = bode(H);
Frequencies are in radians per unit of the model’s TimeUnit property (rad/s by default).
Output and how to read it
The top axis is gain, the bottom axis is phase in degrees, and the horizontal axis is logarithmic frequency. With [mag, phase, wout] = bode(H), wout holds the frequencies used.
The decibel trap
The mag value returned by bode is absolute gain, not decibels, even though the plotted magnitude axis is in dB. Convert it yourself:
magdb = 20*log10(mag);
Forgetting this is the usual reason a value read from a returned array does not match the plot.
Bode plot in Hz instead of rad/s
Two documented ways, depending on whether you use bodeplot as an object or with options:
- Chart-object property:
sys = rss(5); bp = bodeplot(sys); bp.FrequencyUnit = "Hz"; - Options object (good for scripts):
opts = bodeoptions; opts.FreqUnits = 'Hz'; bodeplot(tf(1,[1 1]), opts);Settings in abodeoptionsobject override your session preferences, so the script gives the same figure on any machine.
bode versus bodeplot
| Need | Use | Documented behaviour |
|---|---|---|
| Quick plot, or numeric magnitude and phase arrays | bode |
Plots and, with output arguments, returns mag, phase, wout (and standard deviations for identified models) |
| Customised figure | bodeplot |
Returns a chart object (bp = bodeplot(...)) and accepts bodeoptions or name-value arguments; e.g. hide phase with bp.PhaseVisible = "off" |
| Magnitude only | bodemag |
Plots only the magnitude response |
bodeplot accepts several systems, line specifications, a frequency vector or range, plot options, and name-value pairs, in the forms bodeplot(sys), bodeplot(sys1,...,sysN), bodeplot(___,w), bodeplot(___,plotoptions).
Troubleshooting
- Returned values do not match the plot. Convert
magwith20*log10(mag); the plot is in dB, the array is not. - Axis shows rad/s but you need Hz. Set
FrequencyUnitorFreqUnitsas shown above. - Model has complex coefficients. Use
bp = bodeplot(Gc, Gr); bp.FrequencyScale = "linear";as in the MathWorks example for such models. - Identified or uncertain model fails. These need the System Identification Toolbox or Robust Control Toolbox respectively.
- Plot range looks wrong. The default range is chosen from the system dynamics; pass
{wmin, wmax}to override it.
Free alternatives
| Tool | Function | Documented detail |
|---|---|---|
| Python with the python-control package | control.bode_plot |
Frequency argument omega is in rad/s; Hz=True shows a Hz axis (omega is still rad/s); dB defaults to False; deg defaults to True. Since version 0.10 it returns a ControlPlot object. |
Note the default difference: python-control does not plot decibels unless you ask, while MATLAB’s plot axis is in dB by default.
FAQ
How to plot a Bode plot?
Build a system model (for example H = tf(num, den)) and call bode(H), or bodeplot(H) if you want to customise the chart.
What is the Bode plot?
A paired plot of a system’s gain (in dB) and phase (in degrees) against logarithmic frequency.
How do I create a Bode plot in MATLAB using a transfer function?
Use tf with coefficient vectors, then bode. See the step-by-step section above.
How to make a curve plot in MATLAB?
For a Bode curve, the steps above apply. For a general curve, plot(x, y) graphs vectors; build x with linspace.
How do I get a Bode plot in Hz?
Set bp.FrequencyUnit = "Hz" on the object returned by bodeplot, or set FreqUnits = 'Hz' in a bodeoptions object.
Sources (official documentation, read 2026-11-08)
- MathWorks, bode: Bode frequency response of dynamic system
- MathWorks, bodeplot: Plot Bode frequency response of dynamic system
- python-control documentation, control.bode_plot







