Communications Blockset |

**Sequence Generator Examples**

This section presents two example models that illustrate the blocks in the Sequence Generator library.

**Example: Pseudorandom Sequences**

This example describes the autocorrelation properties of the pseudorandom sequences generated by the following three blocks:

- PN Sequence Generator
- Gold Sequence Generator
- Kasami Sequence Generator

If you are reading this in the MATLAB Help Browser, click here to open the model.

The model displays the output sequences of the three blocks in a scope. All three blocks have the same **Generator polynomial** parameter, `[1 0 0 0 0 1 1]`

, whose digits are the coefficients of the polynomial *x*^{6} + *x* + 1. Since this polynomial has degree 6, the output sequence has period 2^{6} - 1 = 63.

When you run the model, the scope displays two periods of data for each the three signals:

The model also sends the output sequences to the MATLAB workspace as the vectors `pn`

, `gold`

, and `kas`

. You can verify the autocorrelation properties of the output of the PN Sequence Generator by entering the following code at the MATLAB prompt:

x = pn(1:63); % Take one period only x = 1 - 2.*x; % Convert to bipolar for i = 1:63 % Determine the cyclic autocorrelation corrvec(i) = x' * [x(i:end); x(1:i-1)]; end corrvals = unique(sort(corrvec)) % Choose the unique values

The code calculates the cyclic autocorrelation of the PN sequence, by taking the inner product of one period of the sequence with each of its 63 cyclic rotations, and stores the results in a vector, `corrvec`

, of length 63. The code then sorts the entries of `corrvec`

and finds the unique autocorrelation values. The result is

The first entry of the vector corrvec is `63`

, while all other values are `-1`

, as you can verify by entering `corrvec`

at the MATLAB prompt. This means that `63`

occurs only by taking the inner product of the sequence `pn`

with an unrotated copy of itself. All other inner products have the value `-1`

.

You can analyze the output sequences of the Gold Sequence Generator block and the Kasami Sequence Generator block similarly by changing the first line of the preceding code to

For the Gold and Kasami sequences, the autocorrelation takes on three values. For example, the three values for the Gold sequence are

The three values for the Kasami sequence are

Of the three types of sequences, the PN sequences are best suited for synchronization because the autocorrelation takes on just two values. However, the Gold and Kasami sequences provide a larger number of sequences with good cross-correlation properties than do the PN sequences.

Also note that the peak value of `corrvals`

for the Kasami sequence is less than the peak value for the Gold sequence. In fact, the small set of Kasami sequences satisfy the lower bounds for correlation values, and for this reason they are also referred to as optimal sequences.

**Example: Orthogonal Sequences**

This example demonstrates the orthogonality of pairs of sequences generated using different **Code index** parameters, for each of the following three blocks:

- Hadamard Code Generator
- Walsh Code Generator
- OVSF Code Generator

If you are reading this in the MATLAB Help Browser, click here to open the model.

The model displays the output sequences of the three blocks in a scope. All three blocks output sequences of period 64, corresponding to their **Code length** parameters. When you run the model, the scope displays two periods of data for each sequence.

The following code runs the model twice, the first time with the **Code index** parameter of `60`

for all three blocks, and the second time with a **Code index** of `30`

. The code then calculates, for each of the three blocks, the cross correlation between the sequence generated by the first run with the sequence generated by the second run

% Simulate once set_param('doc_ortho/Hadamard Code Generator', 'index', '60'); set_param('doc_ortho/Walsh Code Generator', 'index', '60'); set_param('doc_ortho/OVSF Code Generator', 'index', '60'); sim('doc_ortho'); % Store the codes had60 = had(1:64); walsh60 = walsh(1:64); ovsf60 = ovsf(1:64); % Simulate twice set_param('doc_ortho/Hadamard Code Generator', 'index', '31'); set_param('doc_ortho/Walsh Code Generator', 'index', '31'); set_param('doc_ortho/OVSF Code Generator', 'index', '31'); sim('doc_ortho'); % Store the codes had31 = had(1:64); walsh31 = walsh(1:64); ovsf31 = ovsf(1:64); % Calculate the cross-correlation hadcorr = had60(1:64)'*had31(1:64); hadcorr walshcorr = walsh60(1:64)'*walsh31(1:64); walshcorr ovsfcorr = ovsf60(1:64)'*ovsf31(1:64); ovsfcorr

The results show that for each block, the sequence generated by the first run is orthogonal to the sequence generated by the second run.

Sequence Generators | Block Parameters |