# nrPRACHDetect

Detect PRACH transmission

## Syntax

``[index,offset,info] = nrPRACHDetect(carrier,prach,waveform)``
``[index,offset,info] = nrPRACHDetect(___,Name=Value)``

## Description

`nrPRACHDetect` detects physical random access channel (PRACH) transmission in a time-domain waveform. The function generates an internal reference waveform to correlate the input waveform with the generated reference waveform and searches for correlation output peaks that are greater than the detection threshold. The function uses the position of the strongest peak in the correlator output to determine the detected preamble index and the associated timing offset.

example

````[index,offset,info] = nrPRACHDetect(carrier,prach,waveform)` detects PRACH transmission in the time-domain waveform `waveform` for carrier configuration parameters `carrier` and PRACH configuration parameters `prach`. The function generates the internal reference waveform for default PRACH preamble indices from 0 to 63 and selects a default detection threshold based on the input arguments. The function returns the detected PRACH preamble index, `index`, timing offset, `offset`, and detection information, `info`. If `waveform` contains multiple PRACH instances, the function returns the preamble index and timing offset related to the PRACH instance with the strongest peak in the correlation.```
````[index,offset,info] = nrPRACHDetect(___,Name=Value)` specifies options as name-value arguments in addition to the input arguments in the previous syntax. For example, `DetectionThreshold=0.5` sets the detection threshold for the correlation.```

## Examples

collapse all

Create a carrier configuration object with six resource blocks.

`carrier = nrCarrierConfig(NSizeGrid=6);`

Create a PRACH configuration object. Set the cyclic shift configuration index to `1` and the preamble index within the cell to `44`.

```prach = nrPRACHConfig; prach.ZeroCorrelationZone = 1; prach.PreambleIndex = 44;```

Generate a PRACH resource grid for the specified carrier and PRACH configuration.

`prachGrid = nrPRACHGrid(carrier,prach);`

Generate PRACH symbols and indices for the specified carrier and PRACH configuration.

```prachSymbols = nrPRACH(carrier,prach); prachIndices = nrPRACHIndices(carrier,prach);```

Map the PRACH symbols to the PRACH resource grid.

`prachGrid(prachIndices) = prachSymbols;`

OFDM-modulate the PRACH resource grid to obtain a transmit waveform with PRACH instances.

`tx = nrPRACHOFDMModulate(carrier,prach,prachGrid);`

Create a received waveform by introducing a delay in the transmit waveform.

`rx = [zeros(7,1); tx];`

Detect PRACH instances in the received waveform. Confirm that the delay introduced in the waveform offsets the timing of the PRACH detection.

`[index,offset] = nrPRACHDetect(carrier,prach,rx)`
```index = 44 ```
```offset = 7.1895 ```

## Input Arguments

collapse all

Carrier configuration parameters for a specific OFDM numerology, specified as an `nrCarrierConfig` object. Only these object properties are relevant for this function.

PRACH configuration parameters, specified as an `nrPRACHConfig` object. Apart from the `PreambleIndex` property of `prach`, all object properties are relevant for this function.

Time-domain waveform, specified as a complex-valued matrix of size N-by-P.

• N is the number of time-domain samples in the waveform. If N is less than the number of samples that is needed to analyze this configuration, the function appends zeros at the end of the waveform.

• P is the number of receive antennas.

Data Types: `double`
Complex Number Support: Yes

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: `DetectionThreshold=0.5` sets the detection threshold for the correlation.

Detection threshold for the correlation, specified as `[]` or a real number in the range [0, 1]. When you set this input to `[]`, or if you do not specify this input, the function selects a default value based on these elements of the input arguments `prach` and `waveform`.

• PRACH format, specified by `prach`.`Format`.

• LRA value, specified by `prach`.`LRA`.

• ${N}_{SYM}$ — Number of OFDM symbols per one PRACH preamble, which is equal to `prach`.`PRACHDuration` – 2 for PRACH format C2 and `prach`.`PRACHDuration` for all other PRACH formats.

• $P$ — Number of receive antennas, which is the number of columns in the input waveform `waveform`.

This table provides the formulas that the function uses to calculate default detection thresholds for different LRA values.

`839`$\frac{0.02}{\sqrt{P×{N}_{SYM}}}$
`139`$\frac{0.1}{\sqrt{P×{N}_{SYM}}}$
`1151`$\frac{0.01}{\sqrt{P×{N}_{SYM}}}+0.0005$
`571`$\frac{0.02}{\sqrt{P×{N}_{SYM}}}+0.001$

Data Types: `double`

Set of PRACH preamble indices within the cell for the detection, specified as `[]` or an integer-valued array. The array must have at most 64 elements with integer values in the range from 0 to 63. When you set this input to `[]`, or if you do not specify this input, the function uses default PRACH preamble indices from 0 to 63.

Data Types: `double`

## Output Arguments

collapse all

Detected PRACH preamble index, returned as one of these values.

• Nonnegative integer — The index corresponds to the strongest correlation peak across default preamble indices from 0 to 63 or the indices that you specify using the `PreambleIndex` name-value input argument.

• `[]` — No correlation peak exists above the detection threshold.

Data Types: `double`

Timing offset of the PRACH waveform in samples, from the origin of the input waveform, returned as one of these values.

• Real number — The integer part of this number is the sample position of the strongest correlation peak. The fractional part of this number is the fractional delay present in the correlation peak due to the cyclic shift in the frequency domain.

• `[]` — No correlation peak exists above the detection threshold.

Data Types: `double`

Detection information, returned as a structure containing these fields.

FieldsDescription
`CorrelationPeaks`Strongest correlation peak values, where each value corresponds to default preamble indices from 0 to 63 or the indices that you specify using the `PreambleIndex` name-value input argument.
`DetectionThreshold`Detection threshold that the function uses for the correlation.

## Version History

Introduced in R2022b