Products & Services Solutions Academia Support User Community Company

Learn more about Control System Toolbox   

Converting Between Continuous- and Discrete-Time Representations

Supported Conversion Functions and Methods

The function c2d discretizes continuous-time TF, SS, or ZPK models. Conversely, d2c converts discrete-time TF, SS, or ZPK models to continuous time. Both c2d and d2d support several discretization and interpolation methods, as shown in the following table.

Discretization MethodUse when:
Zero-order hold (ZOH)You want an exact discretization in the time domain for staircase inputs.
First-order hold (FOH)You want an exact discretization in the time domain for piecewise linear inputs.
Impulse-invariant mapping
  • You want an exact discretization in the time domain for impulse train inputs.

  • You do not need exact phase matching in the frequency domain.

Tustin approximation
  • You want good matching in the frequency domain between the continuous- and discrete-time models.

  • Your model has important dynamics near the Nyquist frequency.

Zero-pole matching equivalentsYou have a SISO model, and you want good matching in the frequency domain between the continuous- and discrete-time models.

The default syntax performs a ZOH conversion:

sysd = c2d(sysc, Ts);     % Ts = sampling period in seconds
sysc = d2c(sysd);

You can specify another method as string input to d2c or c2d:

sysd = c2d(sysc, Ts, 'foh');	% use first-order hold
sysc = d2c(sysd, 'tustin');	  % use Tustin approximation

This syntax uses the default options for the specified discretization method. (See the c2d and d2c reference pages for more detail.) You can specify different options for discretizing systems with the 'tustin' or 'matched' methods using c2dOptions or d2cOptions to define the options. For example, to discretize a system using the Tustin method with a prewarp transformation at 4.2 rad/s and a sample time of 0.1 s:

opt = c2dOptions('Method', 'tustin', 'PrewarpFrequency', 4.2);
sysd = c2d(sysc, 0.1, opt);

See c2d and c2dOptions for more information.

Zero-Order Hold Conversion Method

The following block diagram illustrates the zero-order-hold discretization Hd(z) of a continuous-time linear model H(s)

The ZOH block generates the continuous-time input signal u(t) by holding each sample value u(k) constant over one sample period:

The signal u(t) is the input to the continuous system H(s). The output y[k] results from sampling y(t) every Ts seconds.

Conversely, given a discrete system Hd(z), d2c produces a continuous system H(s). The ZOH discretization of H(s) coincides with Hd(z).

The ZOH discrete-to-continuous conversion has the following limitations:

The next example illustrates the behavior of d2c with real negative poles. Consider the following discrete-time zpk model, with one real negative pole at z = –0.5.

hd = zpk([],-0.5,1,0.1)
Zero/pole/gain:
   1
-------
(z+0.5)
 
Sampling time: 0.1

Use d2c to convert this model to continuous-time with the default ZOH method:

hc = d2c(hd)

The result is a second-order model:

Zero/pole/gain:
   4.621 (s+149.3)
---------------------
(s^2 + 13.86s + 1035)

Discretizing the model again returns the original discrete-time system, up to canceling the pole/zero pair at z = –0.5:

c2d(hc,0.1) 

Zero/pole/gain:
 (z+0.5)
---------
(z+0.5)^2
 
Sampling time: 0.1

ZOH Method for Systems with Time Delays

You can use the ZOH method to discretize SISO or MIMO continuous-time models with time delays. The ZOH method yields an exact discretization for systems with I/O delays only (no internal delays).

For more details about how the ZOH method handles systems with time delays, see ZOH, FOH, and Impulse-Invariant Methods in the c2d reference page .

First-Order Hold Conversion Method

First-order hold (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:

This method is generally more accurate than ZOH for systems driven by smooth inputs. Because of causality constraints, you can use this option only for c2d conversions and not d2c conversions.

FOH Method for Systems with Time Delays

You can use the FOH method to discretize SISO or MIMO continuous-time 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 and the c2d reference page for more details.

For more details about how the ZOH method handles systems with time delays, see ZOH, FOH, and Impulse-Invariant Methods in the c2d reference page .

Impulse-Invariant Mapping

The impulse-invariant mapping matches the discretized impulse response to that of the continuous time system. For example:

n = 1; d = [1 1]; % Simple 1st order continuous system 
sc = ss(tf(n, d)); % state space representation 
% Convert to discrete system via impulse invariant mapping 
sd1 = c2d(sc, 0.01, 'impulse');  
impulse(sc,sd1) % Plot both impulse responses 

The impulse response plot shows that the impulse responses match. Impulse-invariant mapping is therefore ideal when you want the discretized system to match the time-domain impulse response of the continuous-time system.

The frequency responses do not match, however. For example:

bode(sc, sd1) 

Impulse-invariant mapping introduces a shift in the DC gain of the discretized system. In addition, it introduces a phase mismatch at higher frequencies. The phase mismatch results from alias effects, and this effect becomes more pronounced as the sampling time increases. For example:

sd2 = c2d(sc, 0.2, 'impulse'); 
sd3 = c2d(sc, 0.5, 'impulse'); 
bode(sc, sd1, sd2, sd3)

While the shift in the DC gain of this system decreases with decreasing sampling time, the aliasing effects become more pronounced. Because of aliasing, impulse-invariant mapping is not a good choice if you want to match the frequency response of the continuous system. In most cases, choose a bilinear transform (such as Tustin Approximation) for preserving the frequency-domain response of the transformed model.

In general, impulse-invariant discretization does not preserve the DC gain. For example, consider the continuous-time transfer function:

The DC gain Gc (0) = 1/a. The impulse-invariant discretization of Gc(s) is:

where Ts is the sampling time. The DC gain of the discretized system is:

For further discussion of impulse invariance scaling issues and aliasing, see [3].

Impulse-Invariant Mapping for Systems with Time Delays

You can use impulse-invariant mapping to discretize SISO or MIMO continuous-time models with time delay, except that the method does not support ss models with internal delays. For supported models, impulse-invariant mapping yields an exact discretization. See the c2d reference page for more information.

Tustin Approximation

The Tustin or bilinear approximation uses the approximation

to relate s-domain and z-domain transfer functions. In c2d conversions, the discretization Hd(z) of a continuous transfer function H(s) is:

Similarly, the d2c conversion relies on the inverse correspondence

Use the Tustin discretization method if you need good frequency domain matching between your continuous-time system and the corresponding discretized system. ( See Impulse-Invariant Mapping.)

For example, the following demonstration shows that in contrast to 'impulse', the 'tustin' method is free of aliasing effects that depend upon sampling time:

n = 1; d = [1 1]; % Simple 1st order continuous system 
sc = ss(tf(n, d)); % state space representation 
% Convert to discrete system with three different sampling times
sd4 = c2d(sc, 0.1, 'tustin'); 
sd5 = c2d(sc, 0.2, 'tustin'); 
sd6 = c2d(sc, 0.5, 'tustin'); 
bode(sc, sd4, sd5, sd6)

Tustin Approximation with Frequency Prewarping

The Tustin approximation with frequency prewarping uses this transformation of variables:

This change of variable ensures the matching of the continuous- and discrete-time frequency responses at the prewarp frequency ω, because of the following correspondence:

To use the Tustin approximation with frequency prewarping, use c2dOptions to specify the prewarp frequency. For example:

n = 1; d = [1 1]; % Simple 1st order continuous system 
sc = ss(tf(n, d)); % state space representation 

% create a c2dOptions object specifying the Tustin method 
% with prewarp frequency 4.2 rad/s
opt = c2dOptions('Method', 'tustin', 'PrewarpFrequency', 4.2);
sd = c2d(sc, 0.01, opt);

Specifying a PrewarpFrequency of 0 is equivalent to using the Tustin method with no prewarp. See the c2d and c2dOptions reference pages for more information about specifying discretization options.

Tustin Approximation for Systems with Time Delays

You can use the Tustin approximation to discretize SISO or MIMO continuous-time models with time delays. The Tustin approximation yields an approximate discretization for a system with 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, by default. You can instead approximate the fractional delay by a Thiran filter using the c2dOptions command.

For example, consider the following transfer function:

To discretize this system using a Thiran filter to approximate a residual fractional delay, enter:

h = tf(10,[1 3 10],'iodelay',0.25); % create transfer function
% define the discretization options
opts = c2dOptions('Method', 'tustin', 'FractDelayApproxOrder', 3);
hdtust = c2d(h, 0.1, opts);

These commands discretize h with a sample time of 0.1 s, approximating the residual fractional time delay as a Thiran filter of order up to 3.

For state-space systems, c2d models the Thiran filter as additional states in the discretized model.

For more details about using the Tustin approximation to discretize systems with time delays, see Tustin Approximation and Zero-Pole Matching Methods on the c2d reference page. For a discussion of Thiran filters, see the thiran reference page and [3].

Zero-Pole Matching Equivalents

The method of conversion by computing zero-pole 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:

where:

See [2] for more details.

Use the zero-pole matching method by specifying the matched method with c2d, c2dOptions, d2c, or d2cOptions. See the reference pages for those commands for more information.

Zero-Pole Matching for Systems with Time Delays

You can use zero-pole matching to discretize SISO continuous-time models with time delay, except that the method does not support ss models with internal delays. The zero-pole matching method handles time delays in the same way as the Tustin approximation. See Tustin Approximation and Zero-Pole Matching Methods on the c2d reference page.

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS