# channelDelay

Channel timing delay

## Description

`[`

computes the channel timing delay by finding the peak of the channel impulse response. The
function reconstructs the impulse response from a channel path gains array and a path filter
impulse response matrix. The function returns the channel timing delay in samples, and the
channel impulse response magnitude. For more information, see Channel Delay and Magnitude Computation.`delay`

,`mag`

] = channelDelay(`pathGains`

,`pathFilters`

)

## Examples

### Compute Timing Delay for 2-by-2 MIMO Channel

Configure a 2-by-2 MIMO channel. Use the `info`

object function to retrieve the path filters.

chan = comm.MIMOChannel('SampleRate',1000,'PathDelays',[0 1.5e-3], ... 'AveragePathGains',[1 0.8],'RandomStream','mt19937ar with seed', ... 'Seed',10,'PathGainsOutputPort',true); chanInfo = info(chan); pathFilters = chanInfo.ChannelFilterCoefficients;

Compute the path gains by passing an impulse through the channel.

[~,pathGains] = chan(ones(1,2));

Compute the channel timing delay, specifying the retrieved path filters and computed path gains.

delay = channelDelay(pathGains,pathFilters)

delay = 6

### Show Relative Timing Delay For Rayleigh Channel

Compute and show the relative timing delay for a Rayleigh channel over time.

Create a `comm.RayleighChannel`

System object configured with three paths and impulse response visualization enabled.

chan = comm.RayleighChannel; chan.SampleRate = 1e3; chan.PathDelays = [0 5.3e-3 10.1e-3]; chan.AveragePathGains = [0.1 1 0.5]; chan.PathGainsOutputPort = true; chan.RandomStream = 'mt19937ar with seed'; chan.Seed = 1; chan.Visualization = 'Impulse response'; chan.MaximumDopplerShift = 1;

Use the `info`

object function to retrieve the Rayleigh channel path filters. In a loop, pass a static signal of all ones through the Rayleigh channel. The `channelDelay`

function uses the channel path gains array from each pass through the channel and the path filter coefficients, `chanInfo.ChannelFilterCoefficients`

(returned by the `info`

function) to compute the relative channel timing delay. The impulse response varies for each iteration. The impulse response for the last iteration is shown here. The `delay`

vector shows the relative channel timing delay computed for each iteration.

chanInfo = info(chan); numIter = 12; delay = zeros(1,numIter); for p=1:numIter [~,pg] = chan(ones(1e3,1)); delay(p) = channelDelay(pg,chanInfo.ChannelFilterCoefficients); end

delay

`delay = `*1×12*
12 7 12 2 12 7 12 7 7 7 2 2

## Input Arguments

`pathGains`

— Channel path gains

4-D array

Channel path gains, specified as an
*N*_{cs}-by-*N*_{p}-by-*N*_{t}-by-*N*_{r}
array, where:

*N*_{cs}is the number of channel snapshots.*N*_{p}is the number of paths.*N*_{t}is the number of transmit antennas.*N*_{r}is the number of receive antennas.

If any element in `pathGains`

is `NaN`

, the
function assumes that no path exists between the transmitter and the receiver.

**Data Types: **`double`

| `single`

**Complex Number Support: **Yes

`pathFilters`

— Path filter impulse response

matrix

Path filter impulse response, specified as an
*N*_{p}-by-*N*_{h}
matrix. *N*_{p} is the number of paths, and
*N*_{h} is the number of impulse response
samples.

**Data Types: **`double`

| `single`

**Complex Number Support: **Yes

## Output Arguments

`delay`

— Channel timing delay

integer

Channel timing delay in samples, returned as an integer. This value represents the
number of samples of delay relative to the first sample of the channel impulse response
reconstructed from the `pathGains`

and
`pathFilters`

inputs. The function computes the channel timing
delay by finding the peak of the composite channel impulse response. For more
information, see Channel Delay and Magnitude Computation.

`mag`

— Channel impulse response magnitude

matrix

Channel impulse response magnitude for each receive antenna, returned as an
*N*_{h}-by-*N*_{r}
matrix. *N*_{h} is the number of impulse response
samples, and *N*_{r} is the number of receive
antennas. For more information, see Channel Delay and Magnitude Computation.

## More About

### Channel Delay and Magnitude Computation

The computation of the channel delay and impulse response magnitudes uses the composite channel impulse response.

The composite channel impulse response results from averaging the impulse response
across all channel snapshots as represented in the path gains array. The input path gains
array must be of the format
*N*_{cs}-by-*N*_{p}-by-*N*_{t}-by-*N*_{r}
, where:

*N*_{cs}is the number of channel snapshots.*N*_{p}is the number of paths.*N*_{t}is the number of transmit antennas.*N*_{r}is the number of receive antennas.

The channel timing delay, output as a single value, is relative to the first sample of the channel impulse response. The function computes this value by finding the peak of the composite channel impulse response. The composite channel impulse response is the summation of the impulse responses across all transmit and receive antennas.

The receive impulse response magnitudes are output as an
*N*_{h}-by-*N*_{r}
matrix. *N*_{h} is the number of impulse response
samples, and *N*_{r} is the number of receive antennas.
To compute the receive impulse response magnitudes,

Path gains are summed across all channel snapshots.

The contribution from each path is added to the channel impulse response across all transmit and receive antennas.

The transmit antenna paths are combined in the channel impulse response array, leaving a matrix of impulse response samples versus receive antennas.

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

## See Also

`comm.MIMOChannel`

| `comm.RayleighChannel`

| `comm.RicianChannel`

**Introduced in R2020a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)