www.gusucode.com > control 案例程序 matlab源码代码 > control/Convert2DOFPIDControllerTo1DOFExample.m

    %% Convert 2-DOF PID controller to 1-DOF
% Design a 2-DOF PID controller for a plant.
%%

% Copyright 2015 The MathWorks, Inc.

G = tf(1,[1 0.5 0.1]);
C2 = pidtune(G,'pidf2',1.5)
%%
% Convert the controller to one degree of freedom.
C1 = make1DOF(C2)
%%
% The new controller has the same PID gains and filter constant.  However,
% |make1DOF| removes the terms involving the setpoint weights |b| and |c|.
% Therefore, in a closed loop with the plant |G|, the 2-DOF controller |C2|
% yields a different closed-loop response from |C1|.
%%
CM = tf(C2);
T2 = CM(1)*feedback(G,-CM(2));
T1 = feedback(G*C1,1);
stepplot(T2,T1,'r--')