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

    %% Convert Discrete-Time Dynamic System to Parallel-Form PID Controller
% Convert a discrete-time dynamic system that represents a PID controller
% with derivative filter to parallel |pid| form.  
%%
% Create a discrete-time zpk model that represents a PIDF controller (two
% zeros and two poles, including the integrator pole at |z| = 1).

% Copyright 2015 The MathWorks, Inc.

sys = zpk([-0.5,-0.6],[1 -0.2],3,'Ts',0.1);
%%
% When you convert |sys| to PID form, the result depends on which discrete
% integrator formulas you specify for the conversion.  For instance, use
% the default, |ForwardEuler|, for both the integrator and the derivative.
Cfe = pid(sys)
%%
% Now convert using the |Trapezoidal| formula.
Ctrap = pid(sys,'IFormula','Trapezoidal','DFormula','Trapezoidal')
%%
% The displays show the difference in resulting coefficient values and
% functional form.
%
% For this particular dynamic system, you cannot write |sys| in parallel
% PID form using the |BackwardEuler| formula for the derivative filter.
% Doing so would result in |Tf < 0|, which is not permitted.  In that case,
% |pid| returns an error.