# commsrc.pattern

Construct pattern generator object

## Syntax

`h = commsrc.pattern`

## Description

`h = commsrc.pattern` constructs a pattern generator object, h. This syntax is equivalent to:

```h = commsrc.pattern('SamplingFrequency', 10000, ... 'SamplesPerSymbol', 100, ... 'PulseType', 'NRZ', ... 'OutputLevels', [-1 1], ... 'RiseTime', 0, ... 'FallTime', 0, ... 'DataPattern', 'PRBS7', ... 'Jitter', commsrc.combinedjitter)```

The pattern generator object produces modulated data patterns. This object can also inject jitter into the modulated signal.

## Properties

A pattern generator object has the properties shown on the following table. You can edit all properties, except those explicitly noted otherwise.

PropertyDescription
`Type`Type of pattern generator object (`'Pattern Generator'`). This property is not writable.
`SamplingFrequency`Sampling frequency of the input signal in hertz.
`SymbolRate`The symbol rate of the input signal. This property depends upon the `SamplingFequency` and `SamplesPerSymbol` properties. This property is not writable.
`SamplesPerSymbol`The number of samples representing a symbol. `SamplesPerSymbol` must be an integer. This property affects `SymbolRate`.
`PulseType`The type of pulse the object generates. Pulse types available: return-to-zero (RZ) and nonreturn-to-zero (NRZ). The initial condition for an NRZ pulse is `0`.
`OutputLevels`Amplitude levels that correspond to the symbol indices. For an NRZ pulse, this is a 1-by-2 vector. The first element of the 1-by-2 vector corresponds to the 0th symbol (data bit value 0). The second element corresponds to the 1st symbol (data bit value 1). For an RZ pulse, this is a scalar and the value corresponds to the data bit value `1`.
`DutyCycle`The duty cycle of the pulse the object generates. Displays calculated duty cycle based on pulse parameters. This property is not writable.
`RiseTime`Specifies 10% to 90% rise time of the pulse in seconds.
`PulseDuration`Pulse duration in seconds defined by IEEE STD 181 standard. (See the Return-to-Zero (RZ) Signal Conversion: Ideal Pulse to STD–181 figure in the Methods section.) Setting `PulseType` to return-to-zero enables this property.
`FallTime`Specifies 10% to 90% fall time of the pulse in seconds.
`DataPattern`The bit sequence the object uses. The following patterns are available: PRBS5 to PRBS15, PRBS23, PRBS31, and User Defined.
`UserDataPattern`User-defined bit pattern consisting of a vector of ones and zeroes. Setting data pattern to `user defined` enables this property.
`Jitter`Specifies jitter characteristics. Use this property to configure Random, Periodic and Dual Dirac Jitter.

## Methods

A pattern generator object has five methods, as described in this section.

### generate

This method outputs a frame worth of modulated and interpolated symbols. It has one input argument, which is the number of symbols in a frame. Its output is a double-column vector. You can call this method using the following syntax

`x = generate(h, N)`
where h is the handle to the object, N is the number of output symbols, and x is a double-column vector.

### reset

This method resets the pattern generator to its default state. The property values do not reset unless they relate to the state of the object. This method has no input arguments.

### idealtostd181

This method converts the ideal pulse specifications to IEEE STD-181 specifications: 0% to 100% rise time (TR) and fall time (TF) convert to 10% to 90% rise and fall times with a 50% pulse width duration, as shown in the following figure. This method also sets the appropriate properties.

idealtostd181(tR, tF, PW)

IEEE STD-181 Return-to-Zero (RZ) Signal Parameters

### std181toideal

This method converts the IEEE STD-181 pulse specifications, stored in the pattern generator, to ideal pulse specifications. This method converts the 10% to 90% rise and fall times to 0% to 100% rise and fall times (TR and TF). It also converts the 50% pulse duration to pulse width (as shown in the following figure). Use the property values for IEEE STD-181 specifications

`[tr tf pw] = stdstd181toideal(h) `
where h is the pattern generator object handle and tR is 0 to 100% rise time.

Ideal Pulse Non-Return-to-Zero (NRZ) Signal Parameters

### computedcd

Computes the duty cycle distortion, DCD, of the pulse defined by the pattern generator object h.

DCD represents the ratio of the pulse on duration to the pulse off duration. For an NRZ pulse, on duration is the duration the pulse spends above the symbol boundary level. Off duration is the duration the pulse spends below zero.

`dcd = computedcd(h)`

The software calculates DCD given tR, tF, Tsym. This formula assumes that the symbol boundary level is zero.

Th = (Ah-Al) * $\frac{{t}_{R}}{{A}_{l}}$ + (Ah-Al) * $\frac{{t}_{F}}{{A}_{l}}$ + PW+

Tl = (Ah-Al) *$\frac{{t}_{R}}{{A}_{l}}$ + (Ah-Al) *$\frac{{t}_{F}}{{A}_{l}}$ + PW-

DCD = $\frac{{T}_{h}}{{T}_{l}}$

Where Th is the duration of the high signal, Tl is the duration of the low signal, and DCD represents the ratio of the duration of the high signal to the low signal.