Getting Started | ![]() ![]() |
Continuous/Discrete Conversions
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
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
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 Sampling time: 0.01 Discrete-time model.
To see the discrete-time transfer function for the digital DC motor, use tf
to convert the model.
fd=tf(sysd) Transfer function: 7.16e-005 z + 6.833e-005 ------------------------ z^2 - 1.866 z + 0.8694 Sampling time: 0.01
![]() | Feedback Interconnection | Model Order Reduction | ![]() |