Documentation

# d2d

Resample discrete-time model

## Syntax

```sys1 = d2d(sys, Ts) sys1 = d2d(sys, Ts, 'method') sys1 = d2d(sys, Ts, opts) ```

## Description

`sys1 = d2d(sys, Ts)` resamples the discrete-time dynamic system model `sys` to produce an equivalent discrete-time model `sys1` with the new sample time `Ts` (in seconds), using zero-order hold on the inputs.

```sys1 = d2d(sys, Ts, 'method')``` uses the specified resampling method `'method'`:

• `'zoh'` — Zero-order hold on the inputs

• `'tustin' ` — Bilinear (Tustin) approximation

For information about the algorithms for each `d2d` conversion method, see Continuous-Discrete Conversion Methods.

`sys1 = d2d(sys, Ts, opts)` resamples `sys` using the option set with `d2dOptions`.

## Examples

collapse all

Create the following zero-pole-gain-model with sample time 0.1 seconds.

`$H\left(z\right)=\frac{z-0.7}{z-0.5}$`

`H = zpk(0.7,0.5,1,0.1);`

Resample the model at 0.05 s.

`H2 = d2d(H,0.05)`
```H2 = (z-0.8243) ---------- (z-0.7071) Sample time: 0.05 seconds Discrete-time zero/pole/gain model. ```

Resample `H2` at 0.1 seconds to obtain the original model `H`.

`H3 = d2d(H2,0.1)`
```H3 = (z-0.7) ------- (z-0.5) Sample time: 0.1 seconds Discrete-time zero/pole/gain model. ```

Suppose that you estimate a discrete-time output-error polynomial model with sample time commensurate with the estimation data (0.1 seconds). However, your deployment application requires a faster sampling frequency (0.01 seconds). You can use `d2d` to resample your estimated model.

```load iddata1 z1 z1.Ts```
```ans = 0.1000 ```

`z1` is an `iddata` object containing the estimation input-output data with sample time 0.1 seconds.

Estimate an output-error polynomial model of order `[2 2 1]`.

```sys = oe(z1,[2 2 1]); sys.Ts```
```ans = 0.1000 ```

Resample the model at sample time 0.01 seconds.

```sys2 = d2d(sys,0.01); sys2.Ts```
```ans = 0.0100 ```

`d2d` resamples the model using the zero-order hold method.

## Tips

• Use the syntax `sys1 = d2d(sys,Ts,'method')` to resample `sys` using the default options for `'method'`. To specify `tustin` resampling with a frequency prewarp, use the syntax ```sys1 = d2d(sys,Ts,opts)```. For more information, see `d2dOptions`.

• When `sys` is an identified (IDLTI) model, `sys1` does not include the estimated parameter covariance of `sys`. If you want to translate the covariance while converting the model, use `translatecov`.

Get trial now