# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# delayseq

## Syntax

`shifted_data = delayseq(data,DELAY)shifted_data = delayseq(data,DELAY,Fs)`

## Description

`shifted_data = delayseq(data,DELAY)` delays or advances the input `data` by `DELAY` samples. Negative values of `DELAY` advance `data`, while positive values delay `data`. Noninteger values of `DELAY` represent fractional delays or advances. In this case, the function interpolates. How the `delayseq` function operates on the columns of `data` depends on the dimensions of `data` and `DELAY`:

• If `DELAY` is a scalar, the function applies that shift to each column of `data`.

• If `DELAY` is a vector whose length equals the number of columns of `data`, the function shifts each column by the corresponding vector entry.

• If `DELAY` is a vector and `data` has one column, the function shifts `data` by each entry in `DELAY` independently. The number of columns in `shifted_data` is the vector length of `DELAY`. The kth column of `shifted_data` is the result of shifting `data` by `DELAY(k)`.

`shifted_data = delayseq(data,DELAY,Fs)` specifies `DELAY` in seconds. `Fs` is the sampling frequency of `data`. If `DELAY` is not divisible by the reciprocal of the sampling frequency, `delayseq` interpolates to implement a fractional delay or advance of `data`.

## Input Arguments

 `data` Vector or matrix of real or complex data. `DELAY` Amount by which to delay or advance the input. If you specify the optional `Fs` argument, `DELAY` is in seconds; otherwise, `DELAY` is in samples. `Fs` Sampling frequency of the data in hertz. If you specify this argument, the function assumes `DELAY` is in seconds. Default: `1`

## Output Arguments

 `shifted_data` Result of delaying or advancing the data. `shifted_data` has the same number of rows as `data`, with appropriate truncations or zero padding.

## Examples

Implement integer delay of input sequence in seconds.

```Fs = 1e4; t = 0:1/Fs:0.005; data = cos(2*pi*1000*t)'; % data is a column vector % Delay input by 0.5 milliseconds (5 samples) shifted_data = delayseq(data,0.0005,Fs); subplot(211); plot(t.*1000,data); title('Input'); subplot(212); plot(t.*1000,shifted_data); title('0.5-millisecond delay'); xlabel('milliseconds');```

Implement fractional delay of input sequence in seconds.

```Fs = 1e4; t = 0:1/Fs:0.005; data = cos(2*pi*1000*t)'; % data is a column vector % Delay input by 0.75 milliseconds (7.5 samples) shifted_data = delayseq(data,0.00075,Fs); figure; subplot(211); plot(t.*1000,data); title('Input'); subplot(212); plot(t.*1000,shifted_data); title('0.75-millisecond (fractional) delay'); axis([0 5 -1.1 1.1]); xlabel('milliseconds');```

Note that the values of the shifted sequence differ from the input because of the interpolation resulting from the fractional delay.