%% Discrete-Time PI Controller
% Create a discrete-time PI controller with trapezoidal discretization formula.
% To create a discrete-time PI controller, set the value of Ts and the discretization formula using Name,Value syntax.

C1 = pid(5,2.4,'Ts',0.1,'IFormula','Trapezoidal')    % Ts = 0.1s

%
% Alternatively, you can create the same discrete-time controller by supplying Ts as the fifth input argument after all four PID parameters, Kp, Ki, Kd, and Tf. Since you only want a PI controller, set Kd and Tf to zero.

C2 = pid(5,2.4,0,0,0.1,'IFormula','Trapezoidal')

% The display shows that C1 and C2 are the same.
% Copyright 2015 The MathWorks, Inc.