# nrPRACH

Generate PRACH symbols

## Syntax

``[sym,info] = nrPRACH(carrier,prach)``
``[sym,info] = nrPRACH(carrier,prach,'OutputDataType',datatype)``

## Description

example

````[sym,info] = nrPRACH(carrier,prach)` returns the physical random access channel (PRACH) symbols, as defined in TS 38.211 Section 6.3.3 [1]. The input `carrier` specifies carrier configuration parameters for a specific OFDM numerology. The input `prach` specifies PRACH configuration parameters. The function also returns the structure `info`, which contains carrier-dependent information about the PRACH.```
````[sym,info] = nrPRACH(carrier,prach,'OutputDataType',datatype)` specifies the data type of the PRACH symbols.```

## Examples

collapse all

Configure the PRACH and the carrier with default properties.

```carrier = nrCarrierConfig; prach = nrPRACHConfig;```

Generate PRACH symbols and indices using the specified carrier and PRACH configuration parameters.

```prachSym = nrPRACH(carrier,prach); prachInd = nrPRACHIndices(carrier,prach);```

Generate a PRACH resource grid of all zeros.

`prachGrid = nrPRACHGrid(carrier,prach);`

Map the PRACH symbols to the PRACH resource grid by using the indices.

`prachGrid(prachInd) = prachSym;`

Analyze physical root Zadoff-Chu sequence indices by generating 64 orthogonal PRACH preambles for two different PRACH configurations.

Root Sequence Indices with Single Value

Configure the PRACH and the carrier with default properties.

```carrier = nrCarrierConfig; prach1 = nrPRACHConfig;```

Set the PRACH logical root sequence index to `0`. For this value, the physical root sequence index is `129`, as defined in TS 38.211 Table 6.3.3.1-3.

`prach1.SequenceIndex = 0;`

Set the PRACH cyclic shift configuration index to `1`. For this value, each PRACH preamble has a different cyclic shift value, based on ${\mathit{N}}_{\mathrm{CS}}$ from TS 38.211 Table 6.3.3.1-5.

`prach1.ZeroCorrelationZone = 1;`

Generate 64 PRACH preambles to store the physical root sequence indices and cyclic shift values.

```rootSequence1 = NaN(1,64); cyclicShift1 = NaN(1,64); for preambleIndex = 0:63 prach1.PreambleIndex = preambleIndex; [~,info] = nrPRACH(carrier,prach1); rootSequence1(preambleIndex+1) = info.RootSequence; cyclicShift1(preambleIndex+1) = info.CyclicShift; end```

Verify that in each preamble, the physical root sequence index is `129`, which is the expected value from configuring the logical root sequence index to `0`.

`disp(rootSequence1)`
``` Columns 1 through 13 129 129 129 129 129 129 129 129 129 129 129 129 129 Columns 14 through 26 129 129 129 129 129 129 129 129 129 129 129 129 129 Columns 27 through 39 129 129 129 129 129 129 129 129 129 129 129 129 129 Columns 40 through 52 129 129 129 129 129 129 129 129 129 129 129 129 129 Columns 53 through 64 129 129 129 129 129 129 129 129 129 129 129 129 ```

Verify that each preamble has a different cyclic shift value.

`disp(cyclicShift1)`
``` Columns 1 through 13 0 13 26 39 52 65 78 91 104 117 130 143 156 Columns 14 through 26 169 182 195 208 221 234 247 260 273 286 299 312 325 Columns 27 through 39 338 351 364 377 390 403 416 429 442 455 468 481 494 Columns 40 through 52 507 520 533 546 559 572 585 598 611 624 637 650 663 Columns 53 through 64 676 689 702 715 728 741 754 767 780 793 806 819 ```

Root Sequence Indices with Different Values

Configure another PRACH with default properties.

`prach2 = nrPRACHConfig;`

Set the PRACH logical root sequence index to `0`. For this value, the physical root sequence index is `129`, as defined in TS 38.211 Table 6.3.3.1-3.

`prach2.SequenceIndex = 0;`

Set the PRACH cyclic shift configuration index to `0`. For this value, each PRACH preamble has the same cyclic shift value, equal to `0`, based on TS 38.211 Table 6.3.3.1-5.

`prach2.ZeroCorrelationZone = 0;`

Generate 64 PRACH preambles to store the physical root sequence indices and cyclic shift values.

```rootSequence2 = NaN(1,64); cyclicShift2 = NaN(1,64); for preambleIndex = 0:63 prach2.PreambleIndex = preambleIndex; [~,info] = nrPRACH(carrier,prach2); rootSequence2(preambleIndex+1) = info.RootSequence; cyclicShift2(preambleIndex+1) = info.CyclicShift; end```

Check the physical root sequence indices and cyclic shift values. Even though the logical root sequence index, `prach.SequenceIndex`, is `0`, not every physical root sequence index value is the expected value of `129`. Because the cyclic shift value is zero in each preamble, the function `nrPRACH` obtains the physical root sequence indices by taking consecutive logical index values. The returned physical root sequence indices correspond to logical indices 0 to 63 from TS 38.211 Table 6.3.3.1-3.

`disp(rootSequence2)`
``` Columns 1 through 13 129 710 140 699 120 719 210 629 168 671 84 755 105 Columns 14 through 26 734 93 746 70 769 60 779 2 837 1 838 56 783 Columns 27 through 39 112 727 148 691 80 759 42 797 40 799 35 804 73 Columns 40 through 52 766 146 693 31 808 28 811 30 809 27 812 29 810 Columns 53 through 64 24 815 48 791 68 771 74 765 178 661 136 703 ```
`disp(cyclicShift2)`
``` Columns 1 through 13 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 14 through 26 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 27 through 39 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 40 through 52 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 53 through 64 0 0 0 0 0 0 0 0 0 0 0 0 ```

## Input Arguments

collapse all

Carrier configuration parameters for a specific OFDM numerology, specified as an `nrCarrierConfig` object.

PRACH configuration parameters, specified as an `nrPRACHConfig` object. The function uses only these properties of this input.

Data type of the output symbols, specified as `'double'` or `'single'`.

Data Types: `char` | `string`

## Output Arguments

collapse all

PRACH symbols, returned as a complex column vector or an empty array. The number of symbols depends on the PRACH configuration `prach`. The function returns an empty array when the PRACH preamble is not active in the current slot.

Data Types: `single` | `double`

Carrier-dependent PRACH information, returned as a structure containing these fields:

FieldsDescription
`RootSequence`Index or indices of physical root Zadoff-Chu sequence
`CyclicShift`Cyclic shift or shifts of Zadoff-Chu sequence
`CyclicOffset`Cyclic shift or shifts corresponding to a Doppler shift of 1/TSEQ, where TSEQ is the length of the PRACH sequence (applies to restricted set only)
`NumCyclicShifts`Number of cyclic shifts corresponding to a single PRACH preamble sequence

Note

Logical root sequence index `prach``.SequenceIndex` determines the returned physical root Zadoff-Chu sequence index `RootSequence`, based on TS 38.211 Table 6.3.3.1-3 and Table 6.3.3.1-4. However, if the preamble index within the cell, specified by `prach.PreambleIndex`, results in insufficient amount of cyclic shifts available at index `prach.SequenceIndex`, the function `nrPRACH` obtains the physical root sequence index by taking consecutive logical root sequence indices, following the process described in TS 38.211 Section 6.3.3.1. In this case, the value of `RootSequence` differs from the expected index, specified by `prach.SequenceIndex`. For an example, see Analyze PRACH Root Sequence Indices.

## References

[1] 3GPP TS 38.211. “NR; Physical channels and modulation.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

## Version History

Introduced in R2020a