Reference Tracking and Optimal Control
English translation
Execution conditions
MATLAB · Control System Toolbox
Learning objectives
Examine why reference error remains even with a stable controller, and compare tracking performance with control-input cost.
Choosing reference gain for reference tracking
Starting conditions
, , , , , x(0)=0.
Procedure
- Use and in turn to calculate unit-step responses on the same time axis. Record the responses and steady-state outputs side by side.
- For under , derive in terms of N. Use to find N satisfying , and show your calculations.
- Compare the directly calculated N with the final values of both responses, and explain what the reference gain changed.
Results to retain
- Both step responses and steady-state values, and the equation used to obtain N.
A=[0 1;-2 -3]; B=[0;1]; C=[1 0]; K=place(A,B,[-2 -4]);
N=-1/(C*((A-B*K)\B)); disp(K); disp(N); assert(abs(N-8)<1e-10);
t=linspace(0,5,1001)'; figure; hold on
for gain=[1 N]
y=lsim(ss(A-B*K,B*gain,C,0),ones(size(t)),t);
plot(t,y,'DisplayName',sprintf('N=%g',gain));
end
xlabel('Time [s]'); ylabel('Position'); legend; grid on
Record results and self-check
N | |
Steady-state value | |
Closed-loop Pole |
Points to check
- Do the directly calculated steady-state outputs match the final values of each simulation?
- Do closed-loop poles remain unchanged when N changes?
Trade-off between output error and input cost
Starting conditions
, , and . Use , .
Procedure
- Solve the CARE for each Q and calculate .
- Plot position and control input on the same time axis.
- Compare the integral of squared position error and the integral of squared input separately.
Results to retain
- Position and input plots and a comparison table of both integrals.
figure; hold on
for q=[1 25]
[Kq,P]=lqr(A,B,diag([q 1]),1);
x=initial(ss(A-B*Kq,zeros(2,1),eye(2),zeros(2,1)),[1;0],t); u=-x*Kq';
disp(q); disp(Kq); disp([trapz(t,x(:,1).^2) trapz(t,u.^2)]);
plot(t,x(:,1),'DisplayName',sprintf('q=%g',q));
end
xlabel('Time [s]'); ylabel('Position'); legend; grid on
% TODO: Add control-input plots and poles.
Record results and self-check
q | |
K | |
Position-error integral | |
Input cost |
Points to check
- Are both Q matrices positive definite, with ?
- Do all poles of have negative real parts?
Reference tracking with model error
Starting conditions
Design using nominal B, and change only the actual input gain to and . Use , , .
Procedure
- Find the poles and final step-response value for each actual model.
- Check whether N calculated from the nominal model also achieves the exact reference in every actual model.
- Distinguish the roles of reference-gain adjustment and integral-error feedback.
Results to retain
- Three response curves and a table of final values and errors.
K=[6 3]; figure; hold on
for g=[.8 1 1.2]
Ba=g*B; Acl=A-Ba*K; steady=-C*(Acl\(Ba*8));
y=lsim(ss(Acl,Ba*8,C,0),ones(size(t)),t); disp(g); disp(eig(Acl)); disp(steady);
plot(t,y,'DisplayName',sprintf('g=%g',g));
end
xlabel('Time [s]'); ylabel('Position'); legend; grid on
% TODO: Explain the cause of the error and the role of integral-error feedback.
Record results and self-check
Input gain | |
Pole | |
Final value | |
Tracking error |
Points to check
- Were both the feedback and reference terms multiplied by the actual B_actual?
- Did you check stability before calculating final values?







