# Documentation

### This is machine translation

Translated by
Mouseover 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

collapse all

Delay a cosine signal an integral number of samples.

```fs = 1.0e4; t = 0:1/fs:0.005; signal = cos(2*pi*1000*t)';```

Set the delay to 0.5 ms or 5 samples.

`shifted_signal = delayseq(signal,0.5e-3,fs);`

Plot the original and delayed signals.

```subplot(2,1,1) plot(t.*1000,signal) title('Input') subplot(2,1,2) plot(t.*1000,shifted_signal) title('0.5-msec delay') xlabel('msec')```

Delay a cosine signal a fractional number of samples.

```fs = 1e4; t = 0:1/fs:0.005; signal = cos(2*pi*1000*t)';```

Set the delay to 0.75 ms or 7.5 samples.

`shifted_signal = delayseq(signal,0.75e-3,fs);`

Plot the original and delayed signals.

```subplot(2,1,1) plot(t.*1000,signal) title('Input') subplot(2,1,2) plot(t.*1000,shifted_signal) title('0.75-msec (fractional) delay') axis([0 5 -1.1 1.1]) xlabel('msec')```

Tthe values of the shifted signal differ from the input signal because of the interpolation resulting from the fractional delay.