Main Content

Converting Between Continuous- and Discrete- Time Systems

Available Commands for Continuous/Discrete Conversion

The commands c2d, d2c, and d2d perform continuous to discrete, discrete to continuous, and discrete to discrete (resampling) conversions, respectively.

sysd = c2d(sysc,Ts)  % Discretization w/ sample period Ts
sysc = d2c(sysd)     % Equivalent continuous-time model
sysd1= d2d(sysd,Ts)  % Resampling at the period Ts

Available Methods for Continuous/Discrete Conversion

Various discretization/interpolation methods are available, including zero-order hold (default), first-order hold, Tustin approximation with or without prewarping, and matched zero-pole. For example,

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

Digitizing the Discrete DC Motor Model

You can digitize the DC motor plant using the c2d function and selecting an appropriate sample time. Choosing the right sample time involves many factors, including the performance you want to achieve, the fastest time constant in your system, and the speed at which you expect your controller to run. For this example, choose a time constant of 0.01 second. See SISO Example: The DC Motor for the construction of the SS object sys_dc.

Ts=0.01;
sysd=c2d(sys_dc,Ts)
 
a = 
                        x1           x2
           x1      0.96079  -0.00027976
           x2     0.006994      0.90484
 
 
b = 
                        u1
           x1     0.019605
           x2  7.1595e-005
 
 

c = 
                        x1           x2
           y1            0            1
 
 
d = 
                        u1
           y1            0
 
Sample time: 0.01
Discrete-time model.

To see the discrete-time zero-pole gain for the digital DC motor, use zpk to convert the model.

fd=zpk(sysd)
 
Zero/pole/gain:
7.1595e-005 (z+0.9544)
------------------------
 (z-0.9608) (z-0.9049)
 
Sample time: 0.01

You can compare the step responses of sys_dc and sysd by typing

step(sys_dc,sysd)
This figure shows the result.

Note the step response match. Continuous and FOH-discretized step responses match for models without internal delays.