A closed-loop step response that "looks good" is not a validated design. Before I call a control project finished, I check three things: numeric specs, stability margins, and behaviour under parameter variation. Here is a short MATLAB workflow for that. It needs Control System Toolbox.
1. Write the specs as numbers
Decide the pass/fail limits before you tune anything:
spec.Overshoot = 10; % percent
spec.SettlingTime = 8; % seconds
spec.PhaseMargin = 45; % degrees
spec.GainMargin = 6; % dB
If a requirement has no number, it cannot fail, and so it cannot be verified.
2. Build the loop and measure it
s = tf('s');
G = 1/(s^2 + 2*s + 1); % example plant, replace with your model
C = pidtune(G, 'PID'); % starting point, not a final design
T = feedback(C*G, 1); % closed loop
S = stepinfo(T); % overshoot, settling time, rise time
[Gm, Pm] = margin(C*G); % gain and phase margins of the open loop
GmdB = 20*log10(Gm);
pass = S.Overshoot <= spec.Overshoot && ...
S.SettlingTime <= spec.SettlingTime && ...
Pm >= spec.PhaseMargin && ...
GmdB >= spec.GainMargin;
margin returns the gain margin as a ratio, so convert it to dB before comparing. Print S, Gm, Pm and the pass flag in your report, not only the plot.
3. Sweep the uncertain parameters
A design that passes only at the nominal values is fragile. Vary the parameters you are least sure of and re-run the checks with the same controller:
zetas = linspace(0.7, 1.3, 7);
results = zeros(numel(zetas), 3);
for i = 1:numel(zetas)
Gk = 1/(s^2 + 2*zetas(i)*s + 1);
Tk = feedback(C*Gk, 1);
if isstable(Tk)
Sk = stepinfo(Tk);
results(i,:) = [zetas(i), Sk.Overshoot, Sk.SettlingTime];
else
results(i,:) = [zetas(i), NaN, NaN]; % unstable case
end
end
disp(array2table(results, 'VariableNames', {'zeta','Overshoot','SettlingTime'}))
Any NaN row is an unstable case. Any row outside the specs tells you how much parameter error the design tolerates.
4. Things that make a "passing" result misleading
- Actuator limits ignored. Add saturation to the simulation and check large steps, not only small ones. Integral windup is the classic failure.
- No noise or delay. A derivative term that looks fine on a clean model can amplify measurement noise badly. Filter it.
- Linear model only. If the plant is nonlinear, re-check the result in a nonlinear simulation around more than one operating point.
- Not reproducible. Keep parameters in one script, record the MATLAB version and toolboxes, and make the whole project run from a single entry point.
Summary
Numeric specs, margins and a parameter sweep take little extra code and catch most "works on my model" problems. The snippets above are a pattern; replace the plant and limits with your own.
Disclosure: I run matlabi.ir, a Persian-language service for MATLAB and engineering projects. For Persian readers, here is the page about control engineering project support.
Code: matlab-control-validation-toolkit
Top comments (0)