Create PID controller in parallel form, convert to parallelform PID controller
C = pid(Kp,Ki,Kd,Tf)
C = pid(Kp,Ki,Kd,Tf,Ts)
C = pid(sys)
C = pid(Kp)
C = pid(Kp,Ki)
C = pid(Kp,Ki,Kd)
C = pid(...,Name,Value)
C = pid
creates
a continuoustime PID controller with proportional, integral, and
derivative gains C
= pid(Kp
,Ki
,Kd
,Tf
)Kp
, Ki
,
and Kd
and firstorder derivative filter time
constant Tf
:
$$C={K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{{T}_{f}s+1}.$$
This representation is in parallel form.
If all of Kp
, Ki
, Kd
,
and Tf
are real, then the resulting C
is
a pid
controller object. If one or more of these
coefficients is tunable (realp
or genmat
),
then C
is a tunable generalized statespace (genss
)
model object.
creates
a discretetime PID controller with sample time C
= pid(Kp
,Ki
,Kd
,Tf
,Ts
)Ts
.
The controller is:
$$C={K}_{p}+{K}_{i}IF\left(z\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}.$$
IF(z) and DF(z)
are the discrete integrator formulas for the
integrator and derivative filter. By default, IF(z) = DF(z) = T_{s}z/(z – 1).
To choose different discrete integrator formulas, use the IFormula
and DFormula
properties.
(See Properties for more information
about IFormula
and DFormula
).
If DFormula
= 'ForwardEuler'
(the
default value) and Tf
≠ 0, then Ts
and Tf
must
satisfy Tf > Ts/2
.
This requirement ensures a stable derivative filter pole.
converts
the dynamic system C
= pid(sys
)sys
to a parallel form pid
controller
object.
creates
a continuoustime proportional (P) controller with C
= pid(Kp
)Ki
= 0, Kd
= 0, and Tf
= 0.
creates
a proportional and integral (PI) controller with C
= pid(Kp
,Ki
)Kd
= 0 and Tf
= 0.
creates
a proportional, integral, and derivative (PID) controller with C
= pid(Kp
,Ki
,Kd
)Tf
= 0.
creates
a controller or converts a dynamic system to a C
= pid(...,Name,Value
)pid
controller
object with additional options specified by one or more Name,Value
pair
arguments.

Proportional gain.
When Default: 1 

Integral gain.
When Default: 0 

Derivative gain.
When Default: 0 

Time constant of the firstorder derivative filter.
When Default: 0 

Sample time. To create a discretetime


SISO dynamic system to convert to parallel

Specify optional commaseparated pairs of Name,Value
arguments.
Name
is the argument
name and Value
is the corresponding
value. Name
must appear
inside single quotes (' '
).
You can specify several name and value pair
arguments in any order as Name1,Value1,...,NameN,ValueN
.
Use Name,Value
syntax to set the numerical
integration formulas IFormula
and DFormula
of
a discretetime pid
controller, or to set other
object properties such as InputName
and OutputName
.
For information about available properties of pid
controller
objects, see Properties.

PID controller, represented as a


PID controller gains. The 

Derivative filter time constant. The 

Discrete integrator formula IF(z)
for the integrator of the discretetime $$C={K}_{p}+{K}_{i}IF\left(z\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}.$$
When Default: 

Discrete integrator formula DF(z)
for the derivative filter of the discretetime $$C={K}_{p}+{K}_{i}IF\left(z\right)+\frac{{K}_{d}}{{T}_{f}+DF\left(z\right)}.$$
When Default: 

Time delay on the system input. 

Time delay on the system Output. 

Sample time. For continuoustime models, Changing this property does not discretize or resample the model.
Use Default: 

String representing the unit of the time variable. This property
specifies the units for the time variable, the sample time
Changing this property has no effect on other properties, and
therefore changes the overall system behavior. Use Default: 

Input channel names. Set Alternatively, use automatic vector expansion to assign input
names for multiinput models. For example, if sys.InputName = 'controls'; The input names automatically expand to You can use the shorthand notation Input channel names have several uses, including:
Default: Empty string 

Input channel units. Use Default: Empty string 

Input channel groups. The sys.InputGroup.controls = [1 2]; sys.InputGroup.noise = [3 5]; creates input groups named sys(:,'controls') Default: Struct with no fields 

Output channel names. Set Alternatively, use automatic vector expansion to assign output
names for multioutput models. For example, if sys.OutputName = 'measurements'; The output names automatically expand to You can use the shorthand notation Output channel names have several uses, including:
Default: Empty string 

Output channel units. Use Default: Empty string 

Output channel groups. The sys.OutputGroup.temperature = [1]; sys.InputGroup.measurement = [3 5]; creates output groups named sys('measurement',:) Default: Struct with no fields 

System name. Set Default: 

Any text that you want to associate with the system. Set Default: 

Any type of data you wish to associate with system. Set Default: 

Sampling grid for model arrays, specified as a data structure. For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables. Set the field names of the data structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array. For example, suppose you create a 11by1
array of linear models, sysarr.SamplingGrid = struct('time',0:10) Similarly, suppose you create a 6by9
model array, [zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w) When you display M M(:,:,1,1) [zeta=0.3, w=5] = 25  s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25  s^2 + 3.5 s + 25 ... For model arrays generated by linearizing a Simulink^{®} model
at multiple parameter values or operating points, the software populates Default: 
PID Controller with Proportional and Derivative Gains, and Filter Time Constant (PDF Controller)
Create a continuoustime controller with proportional and derivative gains, and filter time constant (PDF controller).
Kp=1; Ki=0; Kd=3; Tf=0.5; C = pid(Kp,Ki,Kd,Tf)
C = s Kp + Kd *  Tf*s+1 with Kp = 1, Kd = 3, Tf = 0.5 Continuoustime PDF controller in parallel form.
The display shows the controller type, formula, and parameter values.
DiscreteTime PI Controller
Create a discretetime PI controller with trapezoidal discretization formula.
To create a discretetime controller, set the value of Ts
using Name,Value
syntax.
C = pid(5,2.4,'Ts',0.1,'IFormula','Trapezoidal') % Ts = 0.1s
This command produces the result:
Discretetime PI controller in parallel form: Ts*(z+1) Kp + Ki *  2*(z1) with Kp = 5, Ki = 2.4, Ts = 0.1
Alternatively, you can create the same discretetime controller
by supplying Ts
as the fifth argument after all
four PID parameters Kp
, Ki
, Kd
,
and Tf
.
C = pid(5,2.4,0,0,0.1,'IFormula','Trapezoidal');
PID Controller with Custom Input and Output Names
Create a PID controller, and set dynamic system properties InputName
and OutputName
.
C = pid(1,2,3,'InputName','e','OutputName','u');
Array of PID Controllers
Create a 2by3 grid of PI controllers with proportional gain ranging from 1–2 and integral gain ranging from 5–9.
Create a grid of PI controllers with proportional gain varying row to row and integral gain varying column to column. To do so, start with arrays representing the gains.
Kp = [1 1 1;2 2 2]; Ki = [5:2:9;5:2:9]; pi_array = pid(Kp,Ki,'Ts',0.1,'IFormula','BackwardEuler');
These commands produce a 2by3 array of discretetime pid
objects.
All pid
objects in an array must have the same
sample time, discrete integrator formulas, and dynamic system properties
(such as InputName
and OutputName
).
Alternatively, you can use stack
to
build arrays of pid
objects.
C = pid(1,5,0.1) % PID controller Cf = pid(1,5,0.1,0.5) % PID controller with filter pid_array = stack(2,C,Cf); % stack along 2nd array dimension
These commands produce a 1by2 array of controllers. Enter the command:
size(pid_array)
to see the result
1x2 array of PID controller. Each PID has 1 output and 1 input.
Convert PID Controller from Standard to Parallel Form
Convert a standard form pidstd
controller
to parallel form.
Standard PID form expresses the controller actions in terms
of an overall proportional gain K_{p},
integral and derivative times T_{i} and T_{d},
and filter divisor N. You can convert any standard
form controller to parallel form using pid
.
stdsys = pidstd(2,3,4,5); % Standardform controller parsys = pid(stdsys)
These commands produce a parallelform controller:
Continuoustime PIDF controller in parallel form: 1 s Kp + Ki *  + Kd *  s Tf*s+1 with Kp = 2, Ki = 0.66667, Kd = 8, Tf = 0.8
Convert Dynamic System to ParallelForm PID Controller
Convert a continuoustime dynamic system that represents a PID
controller to parallel pid
form.
The dynamic system
$$H\left(s\right)=\frac{3\left(s+1\right)\left(s+2\right)}{s}$$
represents a PID controller. Use pid
to
obtain H(s) to in terms of the
PID gains K_{p}, K_{i},
and K_{d}.
H = zpk([1,2],0,3); C = pid(H)
These commands produce the result:
Continuoustime PID controller in parallel form: 1 Kp + Ki *  + Kd * s s with Kp = 9, Ki = 6, Kd = 3
Convert DiscreteTime ZeroPoleGain Model to ParallelForm PID Controller
Convert a discretetime dynamic system that represents a PID
controller with derivative filter to parallel pid
form.
% PIDF controller expressed in zpk form sys = zpk([0.5,0.6],[1 0.2],3,'Ts',0.1)
The resulting pid
object depends upon the
discrete integrator formula you specify for IFormula
and DFormula
.
For example, if you use the default ForwardEuler
for
both formulas:
C = pid(sys)
returns the result
Discretetime PIDF controller in parallel form: Ts 1 Kp + Ki *  + Kd *  z1 Tf+Ts/(z1) with Kp = 2.75, Ki = 60, Kd = 0.020833, Tf = 0.083333, Ts = 0.1
Converting using the Trapezoidal
formula
returns different parameter values:
C = pid(sys,'IFormula','Trapezoidal','DFormula','Trapezoidal')
This command returns the result:
Discretetime PIDF controller in parallel form: Ts*(z+1) 1 Kp + Ki *  + Kd *  2*(z1) Tf+Ts/2*(z+1)/(z1) with Kp = 0.25, Ki = 60, Kd = 0.020833, Tf = 0.033333, Ts = 0.1
For this particular sys
, you cannot write sys
in
parallel PID form using the BackwardEuler
formula
for DFormula
. Doing so would result in Tf
< 0, which is not permitted. In that
case, pid
returns an error.
Discretize a Continuoustime PID Controller
First, discretize the controller using the 'zoh'
method
of c2d
.
Cc = pid(1,2,3,4) % continuoustime pidf controller Cd1 = c2d(Cc,0.1,'zoh')
c2d
computes new parameters for the discretetime
controller:
Discretetime PIDF controller in parallel form: Ts 1 Kp + Ki *  + Kd *  z1 Tf+Ts/(z1) with Kp = 1, Ki = 2, Kd = 3.0377, Tf = 4.0502, Ts = 0.1
The resulting discretetime controller uses ForwardEuler
(T_{s}/(z–1))
for both IFormula
and DFormula
.
The discrete integrator formulas of the discretized controller
depend upon the c2d
discretization method, as
described in Tips. To use a different IFormula
and DFormula
,
directly set Ts
, IFormula
, and DFormula
to
the desired values:
Cd2 = Cc; Cd2.Ts = 0.1; Cd2.IFormula = 'BackwardEuler'; Cd2.DFormula = 'BackwardEuler';
These commands do not compute new parameter values for the discretized controller. To see this, enter:
Cd2
to obtain the result:
Discretetime PIDF controller in parallel form: Ts*z 1 Kp + Ki *  + Kd *  z1 Tf+Ts*z/(z1) with Kp = 1, Ki = 2, Kd = 3, Tf = 4, Ts = 0.1