Documentation Center 
Convert model from continuous to discrete time
sysd =
c2d(sys,Ts)
sysd =
c2d(sys,Ts,method)
sysd =
c2d(sys,Ts,opts)
[sysd,G]
= c2d(sys,Ts,method)
[sysd,G]
= c2d(sys,Ts,opts)
sysd = c2d(sys,Ts) discretizes the continuoustime dynamic system model sys using zeroorder hold on the inputs and a sample time of Ts seconds.
sysd = c2d(sys,Ts,method) discretizes sys using the specified discretization method method.
sysd = c2d(sys,Ts,opts) discretizes sys using the option set opts, specified using the c2dOptions command.
[sysd,G] = c2d(sys,Ts,method) returns a matrix, G that maps the continuous initial conditions x_{0} and u_{0} of the statespace model sys to the discretetime initial state vector x [0]. method is optional. To specify additional discretization options, use [sysd,G] = c2d(sys,Ts,opts).
sys 
Continuoustime dynamic system model (except frequency response data models). sys can represent a SISO or MIMO system, except that the 'matched' discretization method supports SISO systems only. sys can have input/output or internal time delays; however, the 'matched' and 'impulse' methods do not support statespace models with internal time delays. The following identified linear systems cannot be discretized directly:
For the syntax [sysd,G] = c2d(sys,Ts,opts), sys must be a statespace model. 
Ts 
Sample time. 
method 
String specifying a discretization method:
For more information about discretization methods, see ContinuousDiscrete Conversion Methods. 
opts 
Discretization options. Create opts using c2dOptions. 
sysd 
Discretetime model of the same type as the input system sys. When sys is an identified (IDLTI) model, sysd:

G 
Matrix relating continuoustime initial conditions x_{0} and u_{0} of the statespace model sys to the discretetime initial state vector x [0], as follows:
For statespace models with time delays, c2d pads the matrix G with zeroes to account for additional states introduced by discretizing those delays. See ContinuousDiscrete Conversion Methods for a discussion of modeling time delays in discretized systems. 
Discretize the continuoustime transfer function:
with input delay T_{d} = 0.35 second. To discretize this system using the triangle (firstorder hold) approximation with sample time T_{s} = 0.1 second, type
H = tf([1 1], [1 4 5], 'inputdelay', 0.35); Hd = c2d(H, 0.1, 'foh'); % discretize with FOH method and % 0.1 second sample time Transfer function: 0.0115 z^3 + 0.0456 z^2  0.0562 z  0.009104  z^6  1.629 z^5 + 0.6703 z^4 Sampling time: 0.1
The next command compares the continuous and discretized step responses.
step(H,'',Hd,'')
Discretize the delayed transfer function
using zeroorder hold on the input, and a 10Hz sampling rate.
h = tf(10,[1 3 10],'iodelay',0.25); % create transfer function hd = c2d(h, 0.1) % zoh is the default method
These commands produce the discretetime transfer function
Transfer function: 0.01187 z^2 + 0.06408 z + 0.009721 z^(3) *  z^2  1.655 z + 0.7408 Sampling time: 0.1
In this example, the discretized model hd has a delay of three sampling periods. The discretization algorithm absorbs the residual halfperiod delay into the coefficients of hd.
Compare the step responses of the continuous and discretized models using
step(h,'',hd,'')
Discretize a statespace model with time delay, using a Thiran filter to model fractional delays:
sys = ss(tf([1, 2], [1, 4, 2])); % create a statespace model sys.InputDelay = 2.7 % add input delay
This command creates a continuoustime statespace model with two states, as the output shows:
a = x1 x2 x1 4 2 x2 1 0 b = u1 x1 2 x2 0 c = x1 x2 y1 0.5 1 d = u1 y1 0 Input delays (listed by channel): 2.7 Continuoustime model.
Use c2dOptions to create a set of discretization options, and discretize the model. This example uses the Tustin discretization method.
opt = c2dOptions('Method', 'tustin', 'FractDelayApproxOrder', 3); sysd1 = c2d(sys, 1, opt) % 1s sampling time
These commands yield the result
a = x1 x2 x3 x4 x5 x1 0.4286 0.5714 0.00265 0.06954 2.286 x2 0.2857 0.7143 0.001325 0.03477 1.143 x3 0 0 0.2432 0.1449 0.1153 x4 0 0 0.25 0 0 x5 0 0 0 0.125 0 b = u1 x1 0.002058 x2 0.001029 x3 8 x4 0 x5 0 c = x1 x2 x3 x4 x5 y1 0.2857 0.7143 0.001325 0.03477 1.143 d = u1 y1 0.001029 Sampling time: 1 Discretetime model.
The discretized model now contains three additional states x3, x4, and x5 corresponding to a thirdorder Thiran filter. Since the time delay divided by the sampling time is 2.7, the thirdorder Thiran filter (FractDelayApproxOrder = 3) can approximate the entire time delay.
Discretize an identified, continuoustime transfer function and compare its performance against a directly estimated discretetime model
Estimate a continuoustime transfer function and discretize it.
load iddata1 sys1c = tfest(z1, 2); sys1d = c2d(sys1c, 0.1, 'zoh');
Estimate a second order discretetime transfer function.
sys2d = tfest(z1, 2, 'Ts', 0.1);
Compare the two models.
compare(z1, sys1d, sys2d)
The two systems are virtually identical.
Discretize an identified statespace model to build a onestep ahead predictor of its response.
load iddata2 sysc = ssest(z2, 4); sysd = c2d(sysc, 0.1, 'zoh'); [A,B,C,D,K] = idssdata(sysd); Predictor = ss(AK*C, [K BK*D], C, [0 D], 0.1);
The Predictor is a two input model which uses the measured output and input signals ([z1.y z1.u]) to compute the 1steap predicted response of sysc.
c2dOptions  d2c  d2d  thiran  translatecov