TOOLS / BODE PLOT

Bode plot calculator with margins

Plot the magnitude and phase of L(jω) = K·G(jω) on a logarithmic frequency axis, and find the gain margin, phase margin and both crossover frequencies.

System / G(s) = N(s) / D(s)

Coefficients in descending powers (1 3 2) or an expression such as s(s+1)(s+2).

L(s) = K·G(s); the closed loop is K·G/(1 + K·G) with unity negative feedback.

G(s) =8s² + 6s + 10
Poles of G(s)
−3 ± 1j
Zeros of G(s)
none
DC gain G(0)
0.8
Closed-loop poles at this K (1)
−3 ± 3j
Stability
Closed loop stable: every pole is in the left half-plane.
Gain margin
∞ (no crossing)
Phase crossover ωpc
—
Phase margin
∞ (no crossing)
Gain crossover ωgc
—

Same result in code

MATLAB
% G(s) = (8) / (s^2 + 6s + 10)
G = tf([8], [1 6 10]);
K = 1;
L = K*G;
bode(L); grid on
[Gm, Pm, Wcg, Wcp] = margin(L)   % Gm as a ratio; Wcg = phase crossover, Wcp = gain crossover
Gm_dB = 20*log10(Gm)
Python (python-control)
import control as ct
import numpy as np

G = ct.tf([8], [1, 6, 10])
K = 1
L = K*G
ct.bode_plot(L, dB=True)
gm, pm, wcg, wcp = ct.margin(L)  # gm as a ratio; wcg = phase crossover, wcp = gain crossover
print(20*np.log10(gm), pm, wcg, wcp)

MATLAB uses the Control System Toolbox; Python uses python-control 0.10 or later (pip install control).

WHAT IT COMPUTES

What this calculator computes

Magnitude in decibels, 20·log10|L(jω)|, and phase in degrees, over a frequency range two decades beyond the outermost pole and zero.

For K/(s(s+1)(s+2)) at K = 1 the gain margin is 6 (15.56 dB) at the phase crossover √2 ≈ 1.414 rad/s and the phase margin is 53.4° at the gain crossover 0.446 rad/s. Raising K to 6 removes the gain margin, the same K = 6 the root locus and Routh array give.

READ THE RESULT

How to read the result

  • Gain crossover ωgc: where |L| = 1 (0 dB). Phase margin = 180° + ∠L(jωgc): how much extra phase lag the loop tolerates there.
  • Phase crossover ωpc: where the phase reaches −180° (or −180° ± 360°). Gain margin = 1/|L(jωpc)|, shown in dB: how much the gain can rise before the loop reaches −1.
  • When there are several crossings, all are listed and the smallest margins are highlighted, as MATLAB margin reports them. A negative gain margin in dB means the loop goes unstable when the gain is lowered.
METHOD

Method and conventions

  • The phase is the sum of the angles of the individual pole and zero factors, each continuous in ω, so it is unwrapped by construction: K/(s(s+1)(s+2)) runs smoothly from −90° to −270° instead of jumping back to +90°.
  • Crossover frequencies are bracketed on a dense logarithmic grid and refined by bisection on the exact magnitude and phase.
LIMITS

Margins describe how far the loop is from −1 at two frequencies; they assume the closed loop is stable to begin with. The page checks the closed-loop poles and warns when it is not, or when the open loop has right-half-plane poles; use the Nyquist plot then.