DynamicSystems
ToDiscrete
discretize a system object
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
ToDiscrete (sys, T, opts)
sys
-
System; system object to discretize
T
(optional) algebraic; sampling time
opts
(optional) equation(s) of the form option = value; specify options for the ToDiscrete command
method = forward, backward, bilinear, prewarp, matched, zoh, or foh
Specifies the method used to discretize the system.
frequency = realcons
Specifies the warping or critical frequency in rad/s. This is used only if method = prewarp, otherwise it is ignored.
The ToDiscrete command converts a continuous system, sys, to a discrete system.
The optional parameter T is the sampling time. If not symbolic it must evaluate to a positive number. The default value is set by the sampletime option to DynamicSystems[SystemOptions].
The method option specifies the method of discretization. The following methods are supported: forward rectangle rule (forward), backward rectangle rule (backward), bilinear rule (bilinear), bilinear with prewarping (prewarp), matched poles and zeros (matched), zero-order hold (zoh), and first-order hold or non-causal triangle-hold (foh).
The bilinear rule is also known as the Tustin or Trapezoid rule.
Not all discretization methods can be applied to all system types. The following table describes the usage. An x indicates that the method can be used by the system type. A D indicates that the method is the default for the system type.
System Type
forward
backward
bilinear
prewarp
matched
zoh
foh
State-Space
x
D
Transfer-Function
Coefficients
Zero-Pole-Gain
Diff-Equation
Transformations
Frequency Domain Transformations
The frequency-domain transformations convert rational functions in s to rational functions in z, where s and z are the continuous and discrete complex frequency variables, respectively. The following paragraphs describe the mapping from the s plane to the z plane for each of the defined transformations.
forward : s -> (z-1)/T
backward : s -> (z-1)/z/T
bilinear : s -> 2*(z-1)/(z+1)/T
prewarp : s -> (z-1)/(z+1)/(tan(ω*T/2)/ω) where ω is the critical frequency in rad/s.
matched : poles and zeros in the s-plane map to the z-plane as s -> exp(s*T) = z; zeros at infinity map to -1; the gain at DC is matched. If system has a pole at DC, then the match frequency is arbitrarily chosen.
The z-transform Z is used in the following hold equivalents:
zoh : H(z) = (1-z^(-1))*Z{H(s)/s}
foh : H(z) = (z-1)^2/z/T*Z{H(s)/s^2}
Time Domain Transformations
The time-domain transformations are done on the state-space matrices. The following describes each of the transformations (the foh and zoh transformations handle singular A matrices). The primed matrices represent the transformed matrices. I is the identity matrix.
A' = I + A*T
B' = B*T
C' = C
D' = D
A' = (I - A*T)^(-1)
B' = A'.B*T
C' = C.A'
D' = D + C'.B*T
M = (I - A*T/2)^(-1)
A' = (I + A*T/2).M
B' = M.B*sqrt(T)
C' = C.M*sqrt(T)
D' = D + sqrt(T)/2*C'.B
A' = exp(A*T)
B' = A^(-1).(exp(A*T) - I).B
B' = A^(-2)/T.(exp(A*T) - I)^2.B
D' = D + C.(A^(-2)/T.(exp(A*T) - I) - A^(-1)).B
with⁡DynamicSystems:
sys≔TransferFunction⁡2⁢s3+s2+1s3+2⁢s2+s−10:PrintSystem⁡sys
Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1⁡soutputvariable=y1⁡stf1,1=2⁢s3+s2+1s3+2⁢s2+s−10
Sampling time T
T≔0.1
sys_z1≔ToDiscrete⁡sys,T,method=forward:PrintSystem⁡sys_z1
Transfer Functiondiscrete; sampletime = .11 output(s); 1 input(s)inputvariable=u1⁡zoutputvariable=y1⁡ztf1,1=2.⁢z3−2.950000000⁢z2+2.900000000⁢z−0.9495000000z3−2.800000000⁢z2+2.610000000⁢z−0.8200000000
sys_z2≔ToDiscrete⁡sys,T,method=backward:PrintSystem⁡sys_z2
Transfer Functiondiscrete; sampletime = .11 output(s); 1 input(s)inputvariable=u1⁡zoutputvariable=y1⁡ztf1,1=1.750833333⁢z3−2.950975726⁢z2+2.903379343⁢z−0.9519276535z3−2.841666667⁢z2+2.666666667⁢z−0.8333333333
sys_z3≔ToDiscrete⁡sys,T,method=bilinear:PrintSystem⁡sys_z3
Transfer Functiondiscrete; sampletime = .11 output(s); 1 input(s)inputvariable=u1⁡zoutputvariable=y1⁡ztf1,1=1.861634506⁢z3−2.950856655⁢z2+2.902444973⁢z−0.9511005426z3−2.816118048⁢z2+2.627695800⁢z−0.8206583428
sys_z4≔ToDiscrete⁡sys,T,method=prewarp,frequency=0.3:PrintSystem⁡sys_z4
Transfer Functiondiscrete; sampletime = .11 output(s); 1 input(s)inputvariable=u1⁡zoutputvariable=y1⁡ztf1,1=1.861625101⁢z3−2.950853005⁢z2+2.902437835⁢z−0.9510969468z3−2.816105866⁢z2+2.627669763⁢z−0.8206464690
sys_z5≔ToDiscrete⁡sys,T,method=zoh:PrintSystem⁡sys_z5
Transfer Functiondiscrete; sampletime = .11 output(s); 1 input(s)inputvariable=u1⁡zoutputvariable=y1⁡ztf1,1=2.⁢z3−2.953151801⁢z2+2.902122691⁢z−0.9485180932z3−2.814354067⁢z2+2.624028879⁢z−0.8187307530
sys_z6≔ToDiscrete⁡sys,T,method=foh:PrintSystem⁡sys_z6
Transfer Functiondiscrete; sampletime = .11 output(s); 1 input(s)inputvariable=u1⁡zoutputvariable=y1⁡ztf1,1=8.187307539×10−10⁢z4+2.268487496×109⁢z3−6.692346287×109⁢z2+6.580907699×109⁢z−2.155942816×109z3−2.814354067⁢z2+2.624028879⁢z−0.8187307530
Compare the frequency responses of the four systems.
p0≔MagnitudePlot⁡sys,range=0.1..10,color=red,thickness=2,legend=continuous:
p1≔MagnitudePlot⁡sys_z1,range=0.1..10,color=blue,legend=forward:
p2≔MagnitudePlot⁡sys_z2,range=0.1..10,color=green,legend=backward:
p3≔MagnitudePlot⁡sys_z3,range=0.1..10,color=black,legend=bilinear:
p4≔MagnitudePlot⁡sys_z4,range=0.1..10,color=grey,legend=prewarp:
p5≔MagnitudePlot⁡sys_z5,range=0.1..10,color=cyan,legend=zoh:
p6≔MagnitudePlot⁡sys_z6,range=0.1..10,color=magenta,legend=foh:
plotsdisplay⁡p0,p1,p2,p3,p4,p5,p6
The DynamicSystems[ToDiscrete] command was updated in Maple 18.
The method option was updated in Maple 18.
See Also
DynamicSystems[Resample]
DynamicSystems[SystemOptions]
DynamicSystems[ToContinuous]
Download Help Document