({{, (RefLink[ToDiscreteTimeModel, paclet:ref/ToDiscreteTimeModel])[lsys,τ] 
gives the discrete-time approximation, with sampling period τ, of the continuous-time systems models lsys.}, {, (RefLink[ToDiscreteTimeModel, paclet:ref/ToDiscreteTimeModel])[tfm,τ,z] 
specifies the transform variable z.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ToDiscreteTimeModel, paclet:ref/ToDiscreteTimeModel]) is also known as sampling.

The systems model lsys can be a (RefLink[TransferFunctionModel, paclet:ref/TransferFunctionModel]) or a (RefLink[StateSpaceModel, paclet:ref/StateSpaceModel]).

For a (RefLink[TransferFunctionModel, paclet:ref/TransferFunctionModel]) object sys, (RefLink[ToDiscreteTimeModel, paclet:ref/ToDiscreteTimeModel])[sys,τ] uses \[FormalZ] as the Z-transform variable.

(RefLink[ToDiscreteTimeModel, paclet:ref/ToDiscreteTimeModel]) accepts a (RefLink[Method, paclet:ref/Method]) option that can be used to specify the approximation method.

The settings for (RefLink[Method, paclet:ref/Method]) are the same as for (RefLink[ToContinuousTimeModel, paclet:ref/ToContinuousTimeModel]).

The setting (RefLink[Method, paclet:ref/Method])->{m,"StateSpaceConversion"->(RefLink[Automatic, paclet:ref/Automatic])} computes the approximation using the transfer-function representation, except for the "ZeroOrderHold" and "FirstOrderHold" methods.

OpenersPrimaryExamplesSection(Spacer1)Examples  (18)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

A discrete-time approximation of a continuous-time system:

ToDiscreteTimeModel[(TransferFunctionModelFull[((3 (1+s))/(0.1` +s)), , , ]),1,z]

OpenersExampleSection1(Spacer1)Scope  (6)

Convert a continuous-time transfer-function model to the discrete-time domain:

ToDiscreteTimeModel[(TransferFunctionModelFull[(a/(a+s)), , , ]),1,z]

Convert a continuous-time state-space model to discrete time:

ToDiscreteTimeModel[(StateSpaceModelFull[0, 1, 0, 0, -1, 1, 1, 0, 0, , , ]),τ,z]

Convert a multiple-input, multiple-output system to discrete time:

ToDiscreteTimeModel[(TransferFunctionModelFull[((1.`)/(1+s)), (s/(1+10 s)), (1/((1+s) (1+10 s))), (2/(1+2 s)), , , ]),1,z]

Convert a symbolic system:

ToDiscreteTimeModel[(TransferFunctionModelFull[((a+s)/(b+s)), , , ]),τ,z]

Convert a time-delay (RefLink[TransferFunctionModel, paclet:ref/TransferFunctionModel]):

ToDiscreteTimeModel[(TransferFunctionModelFull[(((E^(-3 s)) s)/(1-2 s+(s^2))), , , ]),1]

Convert a singular descriptor (RefLink[StateSpaceModel, paclet:ref/StateSpaceModel]):

ToDiscreteTimeModel[(StateSpaceModelFull[0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, -7, 1, -1, 16, 12, 0, , , ]),1/2]

OpenersExampleSection2(Spacer1)Options  (5)

OpenersExampleSubsection0(Spacer1)Method  (5)

By default, the approximation is based on the bilinear transformation:

ToDiscreteTimeModel[(TransferFunctionModelFull[(10/(1+s)), , , ]),1,z]

Specify the desired approximation method:

ToDiscreteTimeModel[(TransferFunctionModelFull[((0.5` (4+2.` s+(s^2)))/(s (1+10 s))), , , ]),1,z,Method->"ForwardRectangularRule"]

Compare the various approximation methods:

tfm=(TransferFunctionModelFull[(s/(1+s+(s^2))), , , ]);

Grid[tfmd=Table[{m,ToDiscreteTimeModel[tfm,0.4,z,Method->m]},{m,{"ForwardRectangularRule","BackwardRectangularRule","BilinearTransform","ZeroOrderHold","FirstOrderHold"}}],Background->{None,{{White,LightGray}}},Frame->All]

BodePlot[Join[{Tooltip[tfm]},Apply[Tooltip,Reverse[#]]&/@tfmd],{0.05,(π/0.4)}]

An approximation that preserves the transmission at the specified frequency:

tfm=(TransferFunctionModelFull[(s/(6+s)), , , ]);

tfmd=ToDiscreteTimeModel[tfm,2,z,Method->{"BilinearTransform","CriticalFrequency"->0.5}]

pts=Point[{#}]& /@Through@{{Log10[0.5],20 Log10@Abs[#]}&,{Log10[0.5],((Arg[#])/Degree)}&}@tfm[I 0.5][[1,1]];

BodePlot[{tfm,tfmd},{0.3,0.7},Epilog-> pts]

The bilinear and backward Euler methods may add states to descriptor state-space models:

ToDiscreteTimeModel[(StateSpaceModelFull[-1, 1, -1, 1, (1/2), 0, 1, 0, 1, 2, 1, 0, 0, , , ]),1,Method->"BackwardRectangularRule"]

OpenersExampleSection3(Spacer1)Applications  (1)

Various approximations to a fourth-order Butterworth lowpass filter:

tfmbw4=(TransferFunctionModelFull[(625/((25+3.8268` s+(s^2)) (25+9.2387` s+(s^2)))), , , ]);

methods={"ForwardRectangularRule","BackwardRectangularRule","BilinearTransform",{"BilinearTransform","CriticalFrequency"->2.8},"ZeroOrderHold","FirstOrderHold"};

Grid[tfmbw4d=Table[{m,ToDiscreteTimeModel[tfmbw4,1,z,Method->m]//TransferFunctionExpand},{m,methods}],Background->{None,{{White,LightGray}}},Frame->All]

Bode plots:

BodePlot[Join[{Tooltip[tfmbw4]},Apply[Tooltip,Reverse[#]]&/@tfmbw4d],{2,(π/1)}]

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

A stable transfer-function model:

tfm=(TransferFunctionModelFull[((5+s)/((0.5` +s) (6+s))), , , ]);

The "ForwardRectangularRule" method may not give a stable approximation:

ToDiscreteTimeModel[tfm,1,Method->"ForwardRectangularRule"];

TransferFunctionPoles[%]

The stability of the "BilinearTransform" approximation depends on the critical frequency:

ToDiscreteTimeModel[tfm,1,Method-> {"BilinearTransform","CriticalFrequency"-> 0.5 π}];

Critical frequencies less than the Nyquist frequency give stable approximations:

TransferFunctionPoles[%]

When the critical frequency is more than the Nyquist frequency, the approximation is unstable:

ToDiscreteTimeModel[tfm,1,Method->{"BilinearTransform","CriticalFrequency"->3.5 π}];

TransferFunctionPoles[%]

All other approximations give a stable system if the continuous-time system is stable:

Table[ToDiscreteTimeModel[(TransferFunctionModelFull[(1/(λ+s)), , , ]),τ, Method->m],{m,{"BackwardRectangularRule","ZeroPoleMapping","ZeroOrderHold","FirstOrderHold"}}];

Flatten[Simplify[TransferFunctionPoles[#]]& /@ %]

Map[Refine[Abs[#]<1, τ>0&&λ >0]&, %]

(RefLink[ToContinuousTimeModel, paclet:ref/ToContinuousTimeModel]) is essentially the inverse of (RefLink[ToDiscreteTimeModel, paclet:ref/ToDiscreteTimeModel]):

c2d2c[sys_,τ_,method_]:=ToContinuousTimeModel[ToDiscreteTimeModel[sys,τ,Method-> method],Method->method]

Table[c2d2c[(TransferFunctionModel[(s/(1+s)), ]),1,method],{method,{"ForwardRectangularRule", "BackwardRectangularRule","BilinearTransform","ZeroOrderHold","FirstOrderHold"}}]

Time delays in the resulting system are given relative to the sampling period:

ToDiscreteTimeModel[(StateSpaceModelFull[-(SystemsModelDelay[(Subscript[T, delay])]), 1, 1, 0, , , ]),(Subscript[T, sampling])]

(RefLink[ToDiscreteTimeModel, paclet:ref/ToDiscreteTimeModel]) may add states to systems with neutral time delays:

ToDiscreteTimeModel[(StateSpaceModelFull[1, 0, -2, 0, 0, 0, 1-(SystemsModelDelay[2]), 0, 0, 1, 2, 0, 0, , , ]),1]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ToContinuousTimeModel, paclet:ref/ToContinuousTimeModel])  ▪  (RefLink[ZTransform, paclet:ref/ZTransform])  ▪  (RefLink[MatrixExp, paclet:ref/MatrixExp])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Systems Modeling, paclet:guide/Modeling])}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}, {▪(RefLinkPlain[Descriptor Control Systems, paclet:guide/DescriptorControlSystems])}, {▪(RefLinkPlain[Control Systems, paclet:guide/ControlSystems])}})}})