## Transforming Between Discrete-Time and Continuous-Time Representations

### Why Transform Between Continuous and Discrete Time?

Transforming between continuous-time and discrete-time representations is useful, for example, if you have estimated a discrete-time linear model and require a continuous-time model instead for your application.

You can use `c2d` and `d2c` to transform any linear identified model between continuous-time and discrete-time representations. `d2d` is useful is you want to change the sample time of a discrete-time model. All of these operations change the sample time, which is called resampling the model.

These commands do not transform the estimated model uncertainty. If you want to translate the estimated parameter covariance during the conversion, use `translatecov`.

Note

`c2d` and `d2d` correctly approximate the transformation of the noise model only when the sample time `T` is small compared to the bandwidth of the noise.

### Using the c2d, d2c, and d2d Commands

The following table summarizes the commands for transforming between continuous-time and discrete-time model representations.

CommandDescriptionUsage Example
`c2d`

Converts continuous-time models to discrete-time models.

You cannot use `c2d` for `idproc` models and for `idgrey` models whose `FunctionType` is not `'cd'`. Convert these models into `idpoly`, `idtf`, or `idss` models before calling `c2d`.

To transform a continuous-time model `mod_c` to a discrete-time form, use the following command:

` mod_d = c2d(mod_c,T)`

where `T` is the sample time of the discrete-time model.

`d2c`

Converts parametric discrete-time models to continuous-time models.

You cannot use `d2c` for `idgrey` models whose `FunctionType` is not `'cd'`. Convert these models into `idpoly`, `idtf`, or `idss` models before calling `d2c`.

To transform a discrete-time model `mod_d` to a continuous-time form, use the following command:

` mod_c = d2c(mod_d)`
`d2d`

Resample a linear discrete-time model and produce an equivalent discrete-time model with a new sample time.

You can use the resampled model to simulate or predict output with a specified time interval.

To resample a discrete-time model `mod_d1` to a discrete-time form with a new sample time `Ts`, use the following command:

` mod_d2 = d2d(mod_d1,Ts)`

The following commands compare estimated model `m` and its continuous-time counterpart `mc` on a Bode plot:

```% Estimate discrete-time ARMAX model % from the data m = armax(data,[2 3 1 2]); % Convert to continuous-time form mc = d2c(m); % Plot bode plot for both models bode(m,mc) ```

### Specifying Intersample Behavior

A sampled signal is characterized only by its values at the sampling instants. However, when you apply a continuous-time input to a continuous-time system, the output values at the sampling instants depend on the inputs at the sampling instants and on the inputs between these points. Thus, the `InterSample` data property describes how the algorithms should handle the input between samples. For example, you can specify the behavior between the samples to be piece-wise constant (zero-order hold, `zoh`) or linearly interpolated between the samples (first order hold, `foh`). The transformation formulas for `c2d` and `d2c` are affected by the intersample behavior of the input.

By default, `c2d` and `d2c` use the intersample behavior you assigned to the estimation data. To override this setting during transformation, add an extra argument in the syntax. For example:

```% Set first-order hold intersample behavior mod_d = c2d(mod_c,T,'foh')```

### Effects on the Noise Model

`c2d`, `d2c`, and `d2d` change the sample time of both the dynamic model and the noise model. Resampling a model affects the variance of its noise model.

A parametric noise model is a time-series model with the following mathematical description:

`$\begin{array}{l}y\left(t\right)=H\left(q\right)e\left(t\right)\\ E{e}^{2}=\lambda \end{array}$`

The noise spectrum is computed by the following discrete-time equation:

`${\Phi }_{v}\left(\omega \right)=\lambda T{|H\left({e}^{i\omega T}\right)|}^{2}$`

where $\lambda$ is the variance of the white noise e(t), and $\lambda T$ represents the spectral density of e(t). Resampling the noise model preserves the spectral density $\lambda$T . The spectral density $\lambda$T is invariant up to the Nyquist frequency. For more information about spectrum normalization, see Spectrum Normalization.

`d2d` resampling of the noise model affects simulations with noise using `sim`. If you resample a model to a faster sampling rate, simulating this model results in higher noise level. This higher noise level results from the underlying continuous-time model being subject to continuous-time white noise disturbances, which have infinite, instantaneous variance. In this case, the underlying continuous-time model is the unique representation for discrete-time models. To maintain the same level of noise after interpolating the noise signal, scale the noise spectrum by $\sqrt{{T}_{New}}{{T}_{Old}}}$, where Tnew is the new sample time and Told is the original sample time. before applying `sim`.

## Support Get trial now