Create a PID controller in standard form, convert to standardform PID controller
C = pidstd(Kp,Ti,Td,N)
C = pidstd(Kp,Ti,Td,N,Ts)
C = pidstd(sys)
C = pidstd(Kp)
C = pidstd(Kp,Ti)
C = pidstd(Kp,Ti,Td)
C = pidstd(...,Name,Value)
C = pidstd
creates
a continuoustime PIDF (PID with firstorder derivative filter) controller
object in standard form. The controller has proportional gain C
= pidstd(Kp
,Ti
,Td
,N
)Kp
,
integral and derivative times Ti
and Td
,
and firstorder derivative filter divisor N
:
$$C={K}_{p}\left(1+\frac{1}{{T}_{i}}\frac{1}{s}+\frac{{T}_{d}s}{\frac{{T}_{d}}{N}s+1}\right).$$
creates
a discretetime controller with sample time C
= pidstd(Kp
,Ti
,Td
,N
,Ts
)Ts
.
The discretetime controller is:
$$C={K}_{p}\left(1+\frac{1}{{T}_{i}}IF\left(z\right)+\frac{{T}_{d}}{\frac{{T}_{d}}{N}+DF\left(z\right)}\right).$$
IF(z) and DF(z) are the discrete integrator formulas for the integrator and derivative filter. By default,
$$IF\left(z\right)=DF\left(z\right)=\frac{{T}_{s}}{z1}.$$
To choose different discrete integrator formulas, use the IFormula
and DFormula
inputs.
(See Properties for more information
about IFormula
and DFormula
).
If DFormula
= 'ForwardEuler'
(the
default value) and N
≠ Inf
, then Ts
, Td
,
and N
must satisfy Td/N > Ts/2
. This requirement ensures a stable derivative
filter pole.
converts
the dynamic system C
= pidstd(sys
)sys
to a standard form pidstd
controller
object.
creates
a continuoustime proportional (P) controller with C
= pidstd(Kp
)Ti
= Inf
, Td
= 0, and N
= Inf
.
creates
a proportional and integral (PI) controller with C
= pidstd(Kp
,Ti
)Td
= 0 and N
= Inf
.
creates
a proportional, integral, and derivative (PID) controller with C
= pidstd(Kp
,Ti
,Td
)N
= Inf
.
creates
a controller or converts a dynamic system to a C
= pidstd(...,Name,Value
)pidstd
controller
object with additional options specified by one or more Name,Value
pair
arguments.

Proportional gain.
Default: 1 

Integrator time.
Default: 

Derivative time.
When Default: 0 

Derivative filter divisor.
When Default: 

Sample time. To create a discretetime
Default: 0 (continuous time) 

SISO dynamic system to convert to standard

Specify optional
commaseparated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside 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 pidstd
controller, or to set
other object properties such as InputName
and OutputName
.
For information about available properties of pidstd
controller
objects, see Properties.

The controller type (P, PI, PD, PDF, PID, PIDF) depends upon
the values of When the inputs 

Proportional gain. 

Integral time. 

Derivative time. 

Derivative filter divisor. 

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

Discrete integrator formula DF(z)
for the derivative filter of the discretetime $$C={K}_{p}\left(1+\frac{1}{{T}_{i}}IF\left(z\right)+\frac{{T}_{d}}{\frac{{T}_{d}}{N}+DF\left(z\right)}\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: 

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 name, specified as a character vector. Use this
property to name the input channel of the controller model. For example,
assign the name C.InputName = 'error'; You can use the shorthand notation Input channel names have several uses, including:
Default: Empty character vector, 

Input channel units, specified as a character vector. Use this
property to track input signal units. For example, assign the concentration
units C.InputUnit = 'mol/m^3';
Default: Empty character vector, 

Input channel groups. This property is not needed for PID controller models. Default: 

Output channel name, specified as a character vector. Use this
property to name the output channel of the controller model. For example,
assign the name C.OutputName = 'control'; You can use the shorthand notation Input channel names have several uses, including:
Default: Empty character vector, 

Output channel units, specified as a character vector. Use this
property to track output signal units. For example, assign the unit C.OutputUnit = 'Volts';
Default: Empty character vector, 

Output channel groups. This property is not needed for PID controller models. Default: 

System name, specified as a character vector. For example, Default: 

Any text that you want to associate with the system, stored as a string or a cell array of
character vectors. The property stores whichever data type you
provide. For instance, if sys1.Notes = "sys1 has a string."; sys2.Notes = 'sys2 has a character vector.'; sys1.Notes sys2.Notes ans = "sys1 has a string." ans = 'sys2 has a character vector.' Default: 

Any type of data you want to associate with system, specified as any MATLAB^{®} data type. 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: 
Create a continuoustime standardform PDF controller with proportional gain 1, derivative time 3, and a filter divisor of 6.
C = pidstd(1,Inf,3,6);
C = s Kp * (1 + Td * ) (Td/N)*s+1 with Kp = 1, Td = 3, N = 6 Continuoustime PDF controller in standard form
The display shows the controller type, formula, and coefficient values.
To create a discretetime controller, set the value of
Ts
using
Name,Value
syntax.
C = pidstd(1,0.5,'Ts',0.1,'IFormula','Trapezoidal') % Ts = 0.1s
This command produces the result:
Discretetime PI controller in standard form: 1 Ts*(z+1) Kp * (1 +  * ) Ti 2*(z1) with Kp = 1, Ti = 0.5, Ts = 0.1
Alternatively, you can create the same discretetime
controller by supplying Ts
as the
fifth argument after all four PID parameters
Kp
, Ti
,
Td
, and
N
.
C = pidstd(5,2.4,0,Inf,0.1,'IFormula','Trapezoidal');
Create a PID controller and set dynamic system properties
InputName
and
OutputName
.
C = pidstd(1,0.5,3,'InputName','e','OutputName','u');
Create a 2by3 grid of PI controllers with proportional gain ranging from 1–2 and integral time ranging from 5–9.
Create a grid of PI controllers with proportional gain varying row to row and integral time varying column to column. To do so, start with arrays representing the gains.
Kp = [1 1 1;2 2 2]; Ti = [5:2:9;5:2:9]; pi_array = pidstd(Kp,Ti,'Ts',0.1,'IFormula','BackwardEuler');
These commands produce a 2by3 array of discretetime
pidstd
objects. All
pidstd
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 the stack
command to build arrays of
pidstd
objects.
C = pidstd(1,5,0.1) % PID controller Cf = pidstd(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.
pid
Controller to Standard FormParallel PID form expresses the controller actions in terms
of an proportional, integral, and derivative gains
K_{p},
K_{i}, and
K_{d}, and
a filter time constant
T_{f}. You
can convert a parallel form controller
parsys
to standard form using
pidstd
, provided that:
parsys
is not a pure
integrator (I) controller.
The gains Kp
,
Ki
, and Kd
of parsys
all have the same
sign.
parsys = pid(2,3,4,5); % Standardform controller
stdsys = pidstd(parsys)
These commands produce a parallelform controller:
Continuoustime PIDF controller in standard form: 1 1 s Kp * (1 +  *  + Td * ) Ti s (Td/N)*s+1 with Kp = 2, Ti = 0.66667, Td = 2, N = 0.4
pidstd
Controller from ContinuousTime Dynamic SystemThe dynamic system
$$H\left(s\right)=\frac{3\left(s+1\right)\left(s+2\right)}{s}$$
represents a PID controller. Use pidstd
to obtain H(s) to
in terms of the standardform PID parameters
K_{p},
T_{i}, and
T_{d}.
H = zpk([1,2],0,3); C = pidstd(H)
These commands produce the result:
Continuoustime PID controller in standard form: 1 1 Kp * (1 +  *  + Td * s) Ti s with Kp = 9, Ti = 1.5, Td = 0.33333
pidstd
Controller from DiscreteTime Dynamic SystemYou can convert a discretetime dynamic system that
represents a PID controller with derivative filter to
standard pidstd
form.
% PIDF controller expressed in zpk form sys = zpk([0.5,0.6],[1 0.2],3,'Ts',0.1);
The resulting pidstd
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 = pidstd(sys)
you obtain the result:
Discretetime PIDF controller in standard form: 1 Ts 1 Kp * (1 +  *  + Td * ) Ti z1 (Td/N)+Ts/(z1) with Kp = 2.75, Ti = 0.045833, Td = 0.0075758, N = 0.090909, Ts = 0.1
For this particular sys
, you cannot write
sys
in standard PID form using
the BackwardEuler
formula for the
DFormula
. Doing so would result
in N
< 0, which is not
permitted. In that case, pidstd
returns an error.
Similarly, you cannot write sys
in
standard form using the Trapezoidal
formula for both integrators. Doing so would result in
negative Ti
and
Td
, which also returns an
error.
pidstd
ControllerFirst, discretize the controller using the
'zoh'
method of c2d
.
Cc = pidstd(1,2,3,4); % continuoustime pidf controller Cd1 = c2d(Cc,0.1,'zoh')
Discretetime PIDF controller in standard form: 1 Ts 1 Kp * (1 +  *  + Td * ) Ti z1 (Td/N)+Ts/(z1) with Kp = 1, Ti = 2, Td = 3.2044, N = 4, 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 standard form: 1 Ts*z 1 Kp * (1 +  *  + Td * ) Ti z1 (Td/N)+Ts*z/(z1) with Kp = 1, Ti = 2, Td = 3, N = 4, Ts = 0.1
Use pidstd
either to create a pidstd
controller
object from known PID gain, integral and derivative times, and filter
divisor, or to convert a dynamic system model to a pidstd
object.
To tune a PID controller for a particular plant, use pidtune
or pidTuner
.
Create arrays of pidstd
controllers
by:
In an array of pidstd
controllers, each
controller must have the same sample time Ts
and
discrete integrator formulas IFormula
and DFormula
.
To create or convert to a parallelform controller,
use pid
. Parallel form expresses
the controller actions in terms of proportional, integral, and derivative
gains K_{p}, K_{i} and K_{d},
and a filter time constant T_{f}:
$$C={K}_{p}+\frac{{K}_{i}}{s}+\frac{{K}_{d}s}{{T}_{f}s+1}.$$
There are two ways to discretize a continuoustime pidstd
controller:
Use the c2d
command. c2d
computes
new parameter values for the discretized controller. The discrete
integrator formulas of the discretized controller depend upon the c2d
discretization
method you use, as shown in the following table.
c2d Discretization
Method  IFormula  DFormula 

'zoh'  ForwardEuler  ForwardEuler 
'foh'  Trapezoidal  Trapezoidal 
'tustin'  Trapezoidal  Trapezoidal 
'impulse'  ForwardEuler  ForwardEuler 
'matched'  ForwardEuler  ForwardEuler 
For more information about c2d
discretization
methods, See the c2d
reference
page. For more information about IFormula
and DFormula
,
see Properties .
If you require different discrete integrator
formulas, you can discretize the controller by directly
setting Ts
,
IFormula
, and
DFormula
to the desired values.
(For more information, see Discretize ContinuousTime pidstd Controller.) However, this method does not compute new gain and
filterconstant values for the discretized controller.
Therefore, this method might yield a poorer match between
the continuoustime and discretetime
pidstd
controllers than using
c2d
.
pidTuner
 pidstd2
 pidstddata
 pidtune