The c2d
command discretizes continuoustime
models. Conversely, d2c
converts discretetime
models to continuous time. Both commands support several discretization
and interpolation methods, as shown in the following table.
Discretization Method  Use when: 

ZeroOrder Hold  You want an exact discretization in the time domain for staircase inputs. 
FirstOrder Hold  You want an exact discretization in the time domain for piecewise linear inputs. 
ImpulseInvariant Mapping (c2d only)  You want an exact discretization in the time domain for impulse train inputs. 
Tustin Approximation 

ZeroPole Matching Equivalents  You have a SISO model, and you want good matching in the frequency domain between the continuous and discretetime models. 
The ZeroOrder Hold (ZOH) method provides an exact match between the continuous and discretetime systems in the time domain for staircase inputs.
The following block diagram illustrates the zeroorderhold discretization H_{d}(z) of a continuoustime linear model H(s)
The ZOH block generates the continuoustime input signal u(t) by holding each sample value u(k) constant over one sample period:
$$u\left(t\right)=u\left[k\right],\text{\hspace{1em}}\text{\hspace{1em}}\text{\hspace{1em}}k{T}_{s}\le t\le \left(k+1\right){T}_{s}$$
The signal u(t) is the input to the continuous system H(s). The output y[k] results from sampling y(t) every T_{s} seconds.
Conversely, given a discrete system H_{d}(z), d2c
produces
a continuous system H(s).
The ZOH discretization of H(s) coincides
with H_{d}(z).
The ZOH discretetocontinuous conversion has the following limitations:
d2c
cannot convert LTI models with
poles at z = 0.
For discretetime
LTI models having negative real poles, ZOH d2c
conversion
produces a continuous system with higher order. The model order increases
because a negative real pole in the z domain maps
to a pure imaginary value in the s domain. Such
mapping results in a continuoustime model with complex data. To avoid
this, the software instead introduces a conjugate pair of complex
poles in the s domain.
You can use the ZOH method to discretize SISO or MIMO continuoustime models with time delays. The ZOH method yields an exact discretization for systems with input delays, output delays, or transfer delays.
For systems with internal delays (delays in feedback loops), the ZOH method results in approximate discretizations. The following figure illustrates a system with an internal delay.
For such systems, c2d
performs the following
actions to compute an approximate ZOH discretization:
Decomposes the delay τ as $$\tau =k{T}_{s}+\rho $$ with $$0\le \rho <{T}_{s}$$.
Absorbs the fractional delay $$\rho $$ into H(s).
Discretizes H(s) to H(z).
Represents the integer portion of the delay kT_{s} as an internal discretetime delay z^{–k}. The final discretized model appears in the following figure:
The FirstOrder Hold (FOH) method provides an exact match between the continuous and discretetime systems in the time domain for piecewise linear inputs.
FOH differs from ZOH by the underlying hold mechanism. To turn the input samples u[k] into a continuous input u(t), FOH uses linear interpolation between samples:
$$u\left(t\right)=u\left[k\right]+\frac{tk{T}_{s}}{{T}_{s}}\left(u\left[k+1\right]u\left[k\right]\right),\text{\hspace{1em}}k{T}_{s}\le t\le \left(k+1\right){T}_{s}$$
This method is generally more accurate than ZOH for systems driven by smooth inputs.
This FOH method differs from standard causal FOH and is more appropriately called triangle approximation (see [2], p. 228). The method is also known as rampinvariant approximation.
You can use the FOH method to discretize SISO or MIMO continuoustime models with time delays. The FOH method handles time delays in the same way as the ZOH method. See ZOH Method for Systems with Time Delays.
The impulseinvariant mapping produces a discretetime model with the same impulse response as the continuous time system. For example, compare the impulse response of a firstorder continuous system with the impulseinvariant discretization:
G = tf(1,[1,1]);
Gd1 = c2d(G,0.01,'impulse');
impulse(G,Gd1)
The impulse response plot shows that the impulse responses of the continuous and discretized systems match.
You can use impulseinvariant mapping to discretize SISO or
MIMO continuoustime models with time delay, except that the method
does not support ss
models with internal delays.
For supported models, impulseinvariant mapping yields an exact discretization
of the time delay.
The Tustin or bilinear approximation yields the best frequencydomain match between the continuoustime and discretized systems. This method relates the sdomain and zdomain transfer functions using the approximation:
$$z={e}^{s{T}_{s}}\approx \frac{1+s{T}_{s}/2}{1s{T}_{s}/2}.$$
In c2d
conversions, the discretization H_{d}(z) of
a continuous transfer function H(s) is:
$${H}_{d}\left(z\right)=H\left({s}^{\prime}\right),\text{\hspace{1em}}\text{\hspace{1em}}\text{\hspace{1em}}{s}^{\prime}=\frac{2}{{T}_{s}}\frac{z1}{z+1}$$
Similarly, the d2c
conversion relies on the
inverse correspondence
$$H\left(s\right)={H}_{d}\left({z}^{\prime}\right),\text{\hspace{1em}}\text{\hspace{1em}}\text{\hspace{1em}}{z}^{\prime}=\frac{1+s{T}_{s}/2}{1s{T}_{s}/2}$$
When you convert a statespace model using the Tustin method, the states are not preserved. The state transformation depends upon the statespace matrices and whether the system has time delays. For example, for an explicit (E = I) continuoustime model with no time delays, the state vector w[k] of the discretized model is related to the continuoustime state vector x(t) by:
$$w\left[k{T}_{s}\right]=\left(IA\frac{{T}_{s}}{2}\right)x\left(k{T}_{s}\right)\frac{{T}_{s}}{2}Bu\left(k{T}_{s}\right)=x\left(k{T}_{s}\right)\frac{{T}_{s}}{2}\left(Ax\left(k{T}_{s}\right)+Bu\left(k{T}_{s}\right)\right).$$
T_{s} is the sample time of the discretetime model. A and B are statespace matrices of the continuoustime model.
If your system has important dynamics at a particular frequency that you want the transformation to preserve, you can use the Tustin method with frequency prewarping. This method ensures a match between the continuous and discretetime responses at the prewarp frequency.
The Tustin approximation with frequency prewarping uses the following transformation of variables:
$${H}_{d}\left(z\right)=H\left({s}^{\prime}\right),\text{\hspace{1em}}\text{\hspace{1em}}\text{\hspace{1em}}{s}^{\prime}=\frac{\omega}{\mathrm{tan}\left(\omega {T}_{s}/2\right)}\frac{z1}{z+1}$$
This change of variable ensures the matching of the continuous and discretetime frequency responses at the prewarp frequency ω, because of the following correspondence:
$$H\left(j\omega \right)={H}_{d}\left({e}^{j\omega {T}_{s}}\right)$$
You can use the Tustin approximation to discretize SISO or MIMO continuoustime models with time delays.
By default, the Tustin method rounds any time delay to the nearest
multiple of the sample time. Therefore, for any time delay tau
,
the integer portion of the delay, k*Ts
, maps to
a delay of k
sampling periods in the discretized
model. This approach ignores the residual fractional delay, tau

k*Ts
.
You can to approximate the fractional portion of the delay by
a discrete allpass filter (Thiran filter) of specified order. To
do so, use the FractDelayApproxOrder
option of c2dOptions
.
To understand how the Tustin method handles systems with time delays, consider the following SISO statespace model G(s). The model has input delay τ_{i}, output delay τ_{o}, and internal delay τ.
The following figure shows the general result of discretizing G(s) using the Tustin method.
By default, c2d
converts the time delays
to pure integer time delays. The c2d
command
computes the integer delays by rounding each time delay to the nearest
multiple of the sample time T_{s}.
Thus, in the default case, m_{i} = round(τ_{i}/T_{s}), m_{o} = round(τ_{o}/T_{s}),
and m = round(τ/T_{s})..
Also in this case, F_{i}(z)
= F_{o}(z)
= F(z) = 1.
If you set FractDelayApproxOrder
to a nonzero
value, c2d
approximates the fractional portion
of the time delays by Thiran filters F_{i}(z), F_{o}(z),
and F(z).
The Thiran filters add additional states to the model. The maximum
number of additional states for each delay is FractDelayApproxOrder
.
For example, for the input delay τ_{i}, the order of the Thiran filter F_{i}(z) is:
order(F_{i}(z))
= max(ceil(τ_{i}/T_{s}), FractDelayApproxOrder
).
If ceil(τ_{i}/T_{s}) < FractDelayApproxOrder
,
the Thiran filter F_{i}(z)
approximates the entire input delay τ_{i}.
If ceil(τ_{i}/T_{s})
> FractDelayApproxOrder
, the Thiran filter only
approximates a portion of the input delay. In that case, c2d
represents
the remainder of the input delay as a chain of unit delays z^{–mi},
where
m_{i} = ceil(τ_{i}/T_{s})
– FractDelayApproxOrder
.
c2d
uses Thiran filters and FractDelayApproxOrder
in
a similar way to approximate the output delay τ_{o} and
the internal delay τ.
When you discretizetf
and zpk
models
using the Tustin method, c2d
first aggregates
all input, output, and transfer delays into a single transfer delay τ_{TOT} for
each channel. c2d
then approximates τ_{TOT} as
a Thiran filter and a chain of unit delays in the same way as described
for each of the time delays in ss
models.
For more information about Thiran filters, see the thiran
reference page and [4].
The method of conversion by computing zeropole matching equivalents applies only to SISO systems. The continuous and discretized systems have matching DC gains. Their poles and zeros are related by the transformation:
$${z}_{i}={e}^{{s}_{i}{T}_{s}}$$
where:
z_{i} is the ith pole or zero of the discretetime system.
s_{i} is the ith pole or zero of the continuoustime system.
T_{s} is the sample time.
See [2] for more information.
You can use zeropole matching to discretize SISO continuoustime
models with time delay, except that the method does not support ss
models
with internal delays. The zeropole matching method handles time delays
in the same way as the Tustin approximation. See Tustin Approximation for Systems with Time Delays.
[1] Åström, K.J. and B. Wittenmark, ComputerControlled Systems: Theory and Design, PrenticeHall, 1990, pp. 4852.
[2] Franklin, G.F., Powell, D.J., and Workman, M.L., Digital Control of Dynamic Systems (3rd Edition), Prentice Hall, 1997.
[3] Smith, J.O. III, “Impulse Invariant
Method”, Physical Audio Signal Processing,
August 2007. http://www.dsprelated.com/dspbooks/pasp/Impulse_Invariant_Method.html
.
[4] T. Laakso, V. Valimaki, “Splitting the Unit Delay”, IEEE Signal Processing Magazine, Vol. 13, No. 1, p.3060, 1996.
c2d
 c2dOptions
 d2c
 d2cOptions
 d2d
 thiran