Discrete-Time Model Creation

How to create discrete-time models.

Discrete-Time Transfer Function Model

This example shows how to create a discrete-time transfer function model using tf.

Create the transfer function G(z)=zz22z6 with a sampling time of 0.1 s.

num = [1 0];
den = [1 -2 -6];
Ts = 0.1;
G = tf(num,den,Ts)

num and den are the numerator and denominator polynomial coefficients in descending powers of z. G is a tf model object.

    Tip   Create a discrete-time zpk, ss, and frd models in a similar way by appending a sampling period to the input arguments. For examples, see the reference pages for those commands.

The sampling time is stored in the Ts property of G. Access Ts, using dot notation:


 More About

Discrete-Time Proportional-Integral-Derivative (PID) Controller

Discrete-Time PID Controller Representations

Discrete-time PID controllers are expressed by the following formulas.




  • Kp = proportional gain

  • Ki = integrator gain

  • Kd = derivative gain

  • Tf = derivative filter time




  • Kp = proportional gain

  • Ti = integrator time

  • Td = derivative time

  • N = derivative filter constant

IF(z) and DF(z) are the discrete integrator formulas for the integrator and derivative filter, respectively. Use the IFormula and DFormula properties of the pid or pidstd model objects to set the IF(z) and DF(z) formulas. The next table shows available formulas for IF(z) and DF(z). Ts is the sample time.

IFormula or DFormulaIF(z) or DF(z)
ForwardEuler (default)






If you do not specify a value for IFormula, DFormula, or both, ForwardEuler is used by default.

Create Discrete-Time Standard-Form PID Controller

This example shows how to create a standard-form discrete-time Proportional-Integral-Derivative (PID) controller that has Kp = 29.5, Ti = 1.13, Td = 0.15 N = 2.3, and sample time Ts  0.1 :

C = pidstd(29.5,1.13,0.15,2.3,0.1,...

This command creates a pidstd model with IF(z)=Ts2z+1z1 and DF(z)=Tszz1.

You can set the discrete integrator formulas for a parallel-form controller in the same way, using pid.

 More About

Was this topic helpful?