 ToDiscrete - Maple Help

DynamicSystems

 ToDiscrete
 discretize a system object Calling Sequence ToDiscrete (sys, T, opts) Parameters

 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 Options

 • 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. Description

 • 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 x D x x Transfer-Function x x D x x x Coefficients x x D x x x Zero-Pole-Gain D Diff-Equation D x 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($\mathrm{\omega }$*T/2)/$\mathrm{\omega }$) where $\mathrm{\omega }$ 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.

 • forward

A' = I + A*T

B' = B*T

C' = C

D' = D

 • backward

A' = (I - A*T)^(-1)

B' = A'.B*T

C' = C.A'

D' = D + C'.B*T

 • bilinear

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

 • zoh

A' = exp(A*T)

B' = A^(-1).(exp(A*T) - I).B

C' = C

D' = D

 • foh

A' = exp(A*T)

B' = A^(-2)/T.(exp(A*T) - I)^2.B

C' = C

D' = D + C.(A^(-2)/T.(exp(A*T) - I) - A^(-1)).B Examples

 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$
 > $\mathrm{sys}≔\mathrm{TransferFunction}\left(\frac{2{s}^{3}+{s}^{2}+1}{{s}^{3}+2{s}^{2}+s-10}\right):$$\mathrm{PrintSystem}\left(\mathrm{sys}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({s}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{2}{}{{s}}^{{3}}{+}{{s}}^{{2}}{+}{1}}{{{s}}^{{3}}{+}{2}{}{{s}}^{{2}}{+}{s}{-}{10}}\end{array}\right$ (1)

Sampling time T

 > $T≔0.1$
 ${T}{≔}{0.1}$ (2)
 > $\mathrm{sys_z1}≔\mathrm{ToDiscrete}\left(\mathrm{sys},T,\mathrm{method}=\mathrm{forward}\right):$$\mathrm{PrintSystem}\left(\mathrm{sys_z1}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{discrete; sampletime = .1}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({z}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({z}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{2.}{}\left({{z}}^{{3}}{-}{2.950000000}{}{{z}}^{{2}}{+}{2.900000000}{}{z}{-}{0.9495000000}\right)}{{{z}}^{{3}}{-}{2.800000000}{}{{z}}^{{2}}{+}{2.610000000}{}{z}{-}{0.8200000000}}\end{array}\right$ (3)
 > $\mathrm{sys_z2}≔\mathrm{ToDiscrete}\left(\mathrm{sys},T,\mathrm{method}=\mathrm{backward}\right):$$\mathrm{PrintSystem}\left(\mathrm{sys_z2}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{discrete; sampletime = .1}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({z}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({z}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{1.750833333}{}\left({{z}}^{{3}}{-}{2.950975726}{}{{z}}^{{2}}{+}{2.903379343}{}{z}{-}{0.9519276535}\right)}{{{z}}^{{3}}{-}{2.841666667}{}{{z}}^{{2}}{+}{2.666666667}{}{z}{-}{0.8333333333}}\end{array}\right$ (4)
 > $\mathrm{sys_z3}≔\mathrm{ToDiscrete}\left(\mathrm{sys},T,\mathrm{method}=\mathrm{bilinear}\right):$$\mathrm{PrintSystem}\left(\mathrm{sys_z3}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{discrete; sampletime = .1}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({z}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({z}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{1.861634506}{}\left({{z}}^{{3}}{-}{2.950856655}{}{{z}}^{{2}}{+}{2.902444973}{}{z}{-}{0.9511005426}\right)}{{{z}}^{{3}}{-}{2.816118048}{}{{z}}^{{2}}{+}{2.627695800}{}{z}{-}{0.8206583428}}\end{array}\right$ (5)
 > $\mathrm{sys_z4}≔\mathrm{ToDiscrete}\left(\mathrm{sys},T,\mathrm{method}=\mathrm{prewarp},\mathrm{frequency}=0.3\right):$$\mathrm{PrintSystem}\left(\mathrm{sys_z4}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{discrete; sampletime = .1}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({z}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({z}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{1.861625101}{}\left({{z}}^{{3}}{-}{2.950853005}{}{{z}}^{{2}}{+}{2.902437835}{}{z}{-}{0.9510969468}\right)}{{{z}}^{{3}}{-}{2.816105866}{}{{z}}^{{2}}{+}{2.627669763}{}{z}{-}{0.8206464690}}\end{array}\right$ (6)
 > $\mathrm{sys_z5}≔\mathrm{ToDiscrete}\left(\mathrm{sys},T,\mathrm{method}=\mathrm{zoh}\right):$$\mathrm{PrintSystem}\left(\mathrm{sys_z5}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{discrete; sampletime = .1}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({z}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({z}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{2.}{}\left({{z}}^{{3}}{-}{2.953151801}{}{{z}}^{{2}}{+}{2.902122691}{}{z}{-}{0.9485180932}\right)}{{{z}}^{{3}}{-}{2.814354067}{}{{z}}^{{2}}{+}{2.624028879}{}{z}{-}{0.8187307530}}\end{array}\right$ (7)
 > $\mathrm{sys_z6}≔\mathrm{ToDiscrete}\left(\mathrm{sys},T,\mathrm{method}=\mathrm{foh}\right):$$\mathrm{PrintSystem}\left(\mathrm{sys_z6}\right)$
 $\left[\begin{array}{l}{\mathbf{Transfer Function}}\\ {\mathrm{discrete; sampletime = .1}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({z}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({z}\right)\right]\\ {{\mathrm{tf}}}_{{1}{,}{1}}{=}\frac{{1.637461506}{×}{{10}}^{{-9}}{}\left({{z}}^{{4}}{+}{1.134243744}{×}{{10}}^{{9}}{}{{z}}^{{3}}{-}{3.346173144}{×}{{10}}^{{9}}{}{{z}}^{{2}}{+}{3.290453850}{×}{{10}}^{{9}}{}{z}{-}{1.077971408}{×}{{10}}^{{9}}\right)}{{{z}}^{{3}}{-}{2.814354067}{}{{z}}^{{2}}{+}{2.624028879}{}{z}{-}{0.8187307530}}\end{array}\right$ (8)

Compare the frequency responses of the four systems.

 > $\mathrm{p0}≔\mathrm{MagnitudePlot}\left(\mathrm{sys},\mathrm{range}=0.1..10,\mathrm{color}=\mathrm{red},\mathrm{thickness}=2,\mathrm{legend}="continuous"\right):$
 > $\mathrm{p1}≔\mathrm{MagnitudePlot}\left(\mathrm{sys_z1},\mathrm{range}=0.1..10,\mathrm{color}=\mathrm{blue},\mathrm{legend}="forward"\right):$
 > $\mathrm{p2}≔\mathrm{MagnitudePlot}\left(\mathrm{sys_z2},\mathrm{range}=0.1..10,\mathrm{color}=\mathrm{green},\mathrm{legend}="backward"\right):$
 > $\mathrm{p3}≔\mathrm{MagnitudePlot}\left(\mathrm{sys_z3},\mathrm{range}=0.1..10,\mathrm{color}=\mathrm{black},\mathrm{legend}="bilinear"\right):$
 > $\mathrm{p4}≔\mathrm{MagnitudePlot}\left(\mathrm{sys_z4},\mathrm{range}=0.1..10,\mathrm{color}=\mathrm{grey},\mathrm{legend}="prewarp"\right):$
 > $\mathrm{p5}≔\mathrm{MagnitudePlot}\left(\mathrm{sys_z5},\mathrm{range}=0.1..10,\mathrm{color}=\mathrm{cyan},\mathrm{legend}="zoh"\right):$
 > $\mathrm{p6}≔\mathrm{MagnitudePlot}\left(\mathrm{sys_z6},\mathrm{range}=0.1..10,\mathrm{color}=\mathrm{magenta},\mathrm{legend}="foh"\right):$
 > $\mathrm{plots}\left[\mathrm{display}\right]\left(\mathrm{p0},\mathrm{p1},\mathrm{p2},\mathrm{p3},\mathrm{p4},\mathrm{p5},\mathrm{p6}\right)$  Compatibility

 • The DynamicSystems[ToDiscrete] command was updated in Maple 18.
 • The method option was updated in Maple 18.