# delayest

Estimate time delay (dead time) from data

## Syntax

`nk = delayest(Data)`

nk = delayest(Data,na,nb,nkmin,nkmax,maxtest)

nk = delayest(___,Name,Value)

## Description

`nk = delayest(Data)`

estimates time delay from the single-output data
`Data`

. `data`

can be in the form of a `timetable`

, a comma-separated pair of numeric matrices, or an `iddata`

object. It can also be an `idfrd`

object defining
frequency-response data.

If `data`

is a timetable, the software assumes that the last
variable is the single output. If the timetable contains more variables than you want to
use, or the single output channel is not the last timetable variable, select specific
input and output channels for the delay estimation by specifying the
`InputName`

and `OutputName`

name-value
arguments.

If `data`

is in the form of a numeric matrix pair
*u*,*y*, then *u* must be an
*Ns*-by-*Nu* matrix and *y* must
be an *Ns*-length column vector. Here, *Ns* is the
number of samples and *Nu* is the number of inputs. Since
*u*,*y* contains no sample time information, also
specify the name-value arguments `Ts`

and
`TimeUnit`

`nk`

is returned as an integer or a row vector of integers, containing
the estimated time delay in samples from the input(s) to the output in
`Data`

.

The estimate is based on a comparison of ARX models with different delays:

$$\begin{array}{l}y(t)+{a}_{1}y(t-1)+\mathrm{...}+{a}_{na}y(t-na)=\\ {b}_{1}u(t-nk)+\mathrm{...}+{b}_{nb}u(t-nb-nk+1)+e(t)\end{array}$$

`nk = delayest(Data,na,nb,nkmin,nkmax,maxtest)`

specifies
additional options. The integer `na`

is the order
of the A polynomial (default 2). `nb`

is a row vector
of length equal to the number of inputs, containing the order(s) of
the B polynomial(s) (default all 2). `nkmin`

and `nkmax`

are
row vectors of the same length as the number of inputs, containing
the smallest and largest delays to be tested. Defaults are `nkmin = 0`

and `nkmax = nkmin+20`

.
If `nb`

, `nkmax`

, and/or `nkmin`

are
entered as scalars in the multiple-input case, all inputs will be
assigned the same values. `maxtest`

is the largest
number of tests allowed (default 10,000).

`nk = delayest(___,`

uses additional model options specified by one or more name-value arguments. `Name,Value)`

The available arguments consist of `InputName`

and
`OutputName`

, which are the input and output channel names. Use
these arguments especially when `data`

is a timetable that has more
variables than you want to use. Also use `OutputName`

to identify the
output channels when the timetable `data`

contains more than one
output variable. Otherwise, the software interprets only the last variable as an output
channel.

For example, specify the input and output signal variable names using ```
sys =
delayest(data,'InputName',["u1","u3"],'OutputName',"y1")
```

.

## Version History

**Introduced before R2006a**