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

    %% Discretize a Continuous-Time 2-DOF PID Controller
% Discretize a continuous-time 2-DOF PID controller and specify the integral
% and derivative filter formulas.
%%
% Create a continuous-time controller and discretize it using the
% zero-order-hold method of the |c2d| command.

% Copyright 2015 The MathWorks, Inc.

C2con = pid2(10,5,3,0.5,1,1);  % continuous-time 2-DOF PIDF controller
C2dis1 = c2d(C2con,0.1,'zoh')
%%
% The display shows that |c2d| computes new PID coefficients for the
% discrete-time controller. 
%
% The discrete integrator formulas of the discretized controller depend on
% the |c2d| discretization method, as described in
% <docid:control_ref.bux1out-3>.  For the |zoh| method, both |IFormula| and
% |DFormula| are |ForwardEuler|.
C2dis1.IFormula
C2dis1.DFormula
%%
% If you want to use different formulas from the ones returned by |c2d|,
% then you can directly set the |Ts|, |IFormula|, and |DFormula| properties
% of the controller to the desired values.
C2dis2 = C2con;
C2dis2.Ts = 0.1; 
C2dis2.IFormula = 'BackwardEuler';
C2dis2.DFormula = 'BackwardEuler';
%%
% However, these commands do not compute new PID gains for the discretized
% controller.  To see this, examine |C2dis2| and compare the coefficients to
% |C2con| and |C2dis1|.
C2dis2