Introduction
Welcome to the fourteenth article in our comprehensive MATLAB course series. In the previous article, we explored control system modeling and time-domain analysis. We learned how to create LTI models, analyze step responses, and design basic PID controllers. Now we’re going to explore the frequency domain—a powerful perspective that reveals aspects of system behavior that time-domain analysis can’t easily uncover.
If time-domain analysis is like watching a system’s step response on an oscilloscope, then frequency-domain analysis is like listening to a system’s response to different frequencies. Just as a prism reveals the spectrum of light, frequency-domain analysis reveals how a system responds to signals at different frequencies. This perspective is incredibly powerful: it lets us design controllers that shape the frequency response, analyze stability margins, and handle systems with time delays.
In this article, we’re going to dive deep into frequency-domain analysis using MATLAB’s Control System Toolbox. We’ll learn how to generate and interpret Bode plots, Nyquist plots, and Nichols plots. We’ll learn how to assess stability using gain and phase margins, and how to design lead and lag compensators to meet frequency-domain specifications. We’ll explore root locus design—a graphical method for placing closed-loop poles by adjusting controller gains. And we’ll tie it all together with a complete design example: designing a compensator for a chemical reactor.
By the end of this article, you’ll have a solid foundation in frequency-domain analysis and root locus design. You’ll understand how to use Bode plots and Nyquist plots to analyze stability, how to design lead and lag compensators, and how to use root locus techniques to place closed-loop poles. This knowledge, combined with the time-domain analysis from the previous article, will make you a formidable control systems engineer. Let’s begin our journey into the frequency domain.
Frequency Response: bode(), nyquist(), nichols()
The frequency response of a system is its steady-state response to sinusoidal inputs at different frequencies. If you input a sine wave sin(ωt) with frequency ω (rad/s), the output (after transients die out) is a sine wave at the same frequency, but with possibly different amplitude and phase shift.
The frequency response is described by two functions of frequency ω:
- Magnitude response:
|G(jω)|(how much the amplitude is amplified or attenuated) - Phase response:
∠G(jω)(how much the phase is shifted)
Together, these form the frequency response function G(jω), which is the transfer function evaluated at s = jω.
MATLAB provides three main functions for visualizing frequency response:
bode(): Bode plot (magnitude and phase vs. frequency)nyquist(): Nyquist plot (real vs. imaginary parts ofG(jω))nichols(): Nichols plot (magnitude vs. phase)
Let’s explore each in detail.
Bode Plots: bode()
A Bode plot is a graph of the magnitude (in dB) and phase (in degrees) of G(jω) vs. frequency ω (in rad/s). The frequency axis is logarithmic (base 10), which means each decade (factor of 10 in frequency) occupies the same horizontal space.
Bode plots are enormously useful because:
- They reveal system bandwidth (the frequency range over which the system responds well).
- They show stability margins (gain margin and phase margin).
- They’re intuitive for design: you can shape the frequency response by adding poles, zeros, and gain.
Syntax
% Basic: plot Bode plot
bode(G)
% With frequency vector output
[mag, phase, w] = bode(G)
% Specify frequency range
bode(G, w) % w is a frequency vector (rad/s)
Example: Bode Plot of a Second-Order System
Let’s plot the Bode plot of a second-order system:
% Second-order system
wn = 10; % natural frequency (rad/s)
zeta = 0.3; % damping ratio
G = tf([wn^2], [1 2*zeta*wn wn^2]);
% Plot Bode plot
figure;
bode(G);
grid on;
title('Bode Plot of Second-Order System (wn=10, zeta=0.3)');
The Bode plot shows:
- Magnitude: At low frequencies, the magnitude is approximately
20*log10(1) = 0dB (DC gain = 1). At the natural frequencyωₙ = 10rad/s, there’s a peak (resonance) due to the light damping. At high frequencies, the magnitude decays at-40dB/decade (because it’s a second-order system). - Phase: At low frequencies, the phase is
0°. At the natural frequency, the phase is approximately-90°. At high frequencies, the phase approaches-180°.
Interpreting Bode Plots
Key features to look for on Bode plots:
- Low-frequency magnitude: Determines steady-state error to step inputs (for unity feedback).
- Bandwidth: The frequency at which the magnitude drops by 3 dB from the low-frequency value. Determines speed of response.
- Resonance peak: Indicates light damping (light overshoot in time-domain).
- High-frequency rolloff: Determines how well the system rejects high-frequency noise.
- Phase margin: The difference between the phase at the gain crossover frequency and
-180°. Indicates stability and overshoot. - Gain margin: The amount of gain (in dB) you can add before the system becomes unstable.
We’ll revisit these when we discuss stability margins.
Customizing Bode Plots
You can customize Bode plots using standard MATLAB plotting commands (after bode() creates the plot):
% Plot Bode plot
figure;
bode(G);
grid on;
% Customize (these commands affect the current axes)
% But bode() creates subplots, so you need to get the axes handles
% A simpler approach: use bodeplot() with options
Actually, a better approach is to use the bodeplot() function with a bodeoptions object:
% Create Bode plot options
opts = bodeoptions();
opts.FreqUnits = 'Hz'; % frequency in Hz (instead of rad/s)
opts.MagUnits = 'abs'; % magnitude in absolute (instead of dB)
opts.PhaseUnits = 'rad'; % phase in radians (instead of degrees)
opts.Grid = 'on'; % enable grid
% Plot with options
figure;
bodeplot(G, opts);
title('Bode Plot with Custom Options');
Nyquist Plots: nyquist()
A Nyquist plot is a polar plot of the frequency response: the real part of G(jω) vs. the imaginary part of G(jω), as ω varies from 0 to ∞. By symmetry, the plot for negative frequencies (ω from 0 to -∞) is the mirror image across the real axis.
The Nyquist plot is primarily used for stability analysis via the Nyquist criterion (which we’ll cover in detail later). It’s less intuitive than Bode plots for design, but it’s more general (it can handle time delays and other non-rational transfer functions).
Syntax
% Basic: plot Nyquist plot
nyquist(G)
% With output
[re, im, w] = nyquist(G)
Example: Nyquist Plot of a Second-Order System
G = tf([100], [1 6 100]); % second-order system
figure;
nyquist(G);
grid on;
title('Nyquist Plot of Second-Order System');
The Nyquist plot shows a curve that starts at (1, 0) (for ω = 0) and spirals in toward the origin (for ω → ∞). The curve does not encircle the critical point (-1, 0), which indicates stability (we’ll explain why later).
Interpreting Nyquist Plots
The key to interpreting Nyquist plots is the Nyquist criterion: the number of times the Nyquist plot encircles the critical point (-1, 0) tells you how many closed-loop poles are in the right-half plane (RHP).
We’ll cover this in detail in the “Nyquist Criterion” section.
Nichols Plots: nichols()
A Nichols plot is a plot of magnitude (dB) vs. phase (degrees) of G(jω). It’s like a Bode plot, but with magnitude and phase on orthogonal axes (instead of vs. frequency).
Nichols plots are useful for loop shaping design: you can superimpose Nichols chart contours (which show closed-loop magnitude and phase) and adjust the open-loop frequency response to achieve desired closed-loop specifications.
Syntax
% Basic: plot Nichols plot
nichols(G)
% With output
[mag, phase, w] = nichols(G)
Example: Nichols Plot of a Second-Order System
G = tf([100], [1 6 100]);
figure;
nichols(G);
grid on;
title('Nichols Plot of Second-Order System');
The Nichols plot shows a curve in the magnitude-phase plane. You can superimpose Nichols chart contours (using the ngrid function) to read off closed-loop properties.
Which Frequency-Domain Plot Should You Use?
Each plot has its strengths:
- Bode plot: Best for design and interpreting stability margins. Most intuitive for engineers.
- Nyquist plot: Best for stability analysis (Nyquist criterion). Can handle time delays and other non-rational systems.
- Nichols plot: Best for loop shaping design. Lets you read closed-loop magnitude and phase directly from the plot (with Nichols chart contours).
In practice, Bode plots are the most widely used. If you’re doing control design, you’ll probably use Bode plots 90% of the time.



