How to create discrete-time models.
|On this page…|
This example shows how to create a discrete-time transfer function model using tf.
Create the transfer function 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.
The sampling time is stored in the Ts property of G. Access Ts, using dot notation:
Discrete-time PID controllers are expressed by the following formulas.
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 DFormula||IF(z) or DF(z)|
If you do not specify a value for IFormula, DFormula, or both, ForwardEuler is used by default.
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,... 'IFormula','Trapezoidal','DFormula','BackwardEuler')
This command creates a pidstd model with and .
You can set the discrete integrator formulas for a parallel-form controller in the same way, using pid.