Control System Design
Model a plant as a transfer function, analyse stability margins, use root locus, then tune a PID controller for a specified step response.
Step 1 — Define the plant model
A second-order plant G(s) = 10 / (s² + s + 10) is a common benchmark for control design. Plot the step response to see the uncontrolled behaviour.
G = tf([10], [1, 1, 10]);
stepResponse(G);
title('Open-loop step response')▶ Run in SimLabExpected output: Underdamped step response with significant overshoot
Step 2 — Bode plot and stability margins
The Bode diagram shows gain/phase margins. A robust design needs ≥ 6 dB gain margin and ≥ 45° phase margin. margin() returns an object with Gm, Pm, Wcg, Wcp fields.
bode(G); m = margin(G); disp(m)▶ Run in SimLab
Expected output: Bode plot with margins annotated
Step 3 — Root locus for gain selection
The root locus shows how closed-loop poles move as gain K increases. Click a point on the locus to read off a good gain.
rlocus(G)▶ Run in SimLab
Expected output: Root locus plot
Step 4 — Add a PID controller
A PID controller C(s) = Kp + Ki/s + Kd*s improves the step response. Tune Kp=2, Ki=5, Kd=0.5 and check the closed-loop result.
Kp = 2; Ki = 5; Kd = 0.5;
C = tf([Kd, Kp, Ki], [1, 0]);
T = feedback(C*G, 1);
stepResponse(T);
title('Closed-loop with PID')▶ Run in SimLabExpected output: Faster step response with reduced overshoot
Related Tutorials
Try SimLab — Free MATLAB® Alternative
466 functions. Runs in your browser. No install.
Open SimLab