How to plot Bode, Nyquist, and Nichols stability charts in MATLAB and measure Gain Margin and Phase Margin?
John Michell answered .
2026-07-24
Minimum phase systems have all poles and zeros in the left-half s-plane. In MATLAB, plot stability margins using bode(), nyquist(), and margin():
% Define open-loop transfer function G(s)
G = tf([10], [1 4 5 0]);
figure;
margin(G); % Plots Bode diagram with GM and PM markers
figure;
nyquist(G); % Plots Nyquist stability locus
% Calculate numerical margins
[GM, PM, wcg, wcp] = margin(G);
fprintf('Gain Margin: %.2f dB\n', 20*log10(GM));
fprintf('Phase Margin: %.2f deg\n', PM);