| Communications Toolbox™ | ![]() |
| On this page… |
|---|
Signal modulation generally requires the use of functions, such as fskmod or ssbmod. For DPSK, General QAM, MSK, OQPSK, PAM, PSK, and QAM, however, you modulate signals through the use of modem objects. This section gives an overview of how you use these objects.
A modem object is a type of MATLAB variable that contains information about the modulation algorithm, such as the name of the modulation class, M-ary number, and the constellation mapping. The object can be operated upon using specific methods to perform certain tasks.
To construct modulator and demodulator objects, use the functions (constructors) shown in the following table.
| Modulation Type | Constructors |
|---|---|
| DPSK | modem.dpskmod and modem.dpskdemod |
| General QAM | modem.genqammod and modem.genqamdemod |
| MSK | modem.mskmod and modem.mskdemod |
| OQPSK | modem.oqpskmod and modem.oqpskdemod |
| PAM | modem.pammod and modem.pamdemod |
| PSK | modem.pskmod and modem.pskdemod |
| QAM | modem.qammod and modem.qamdemod |
See individual reference pages for details.
To view the properties of a modem object, use its disp method, as shown in the following example:
h=modem.pskmod; % Construct a PSK modulator object. h.disp % Display object properties.
You can directly assign a value to a property as follows:
h=modem.pskmod(8); % Construct a PSK modulator object. % Set the 'symbolorder' property of the object to 'gray'. h.symbolorder='gray';
The properties can also be set to specific values when constructing the object. See reference pages of individual objects for details.
The syntax h = copy(refobj) creates a new instance of an object, h, of the same type as refobj, and copies the properties of refobj into h.
Setting another variable equal to an object just copies its handle, and is not creating an independent copy of it. Thus, in the previous example, if you set a = h, then a points to the same object h and any changes made to h are also reflected in a.
The syntax disp(h) displays relevant properties of object h.
If a property is not relevant to the object's configuration, it does not display. For example, for a MODEM.PSKDEMOD object, NoiseVariance property is not relevant when DecisionType property is set to 'Hard decision', hence NoiseVariance property does not display.
The following is an example of using disp:
h = modem.pskmod; % create an object with default properties
disp(h); % display object properties The output for this example looks like:
Type: 'PSK Modulator'
M: 2
PhaseOffset: 0
Constellation: [1 -1+i*1.22464679914735e-16]
SymbolOrder: 'Binary'
SymbolMapping: [0 1]
InputType: 'Integer'
The following is an example of using disp:
h = modem.qamdemod('M', 32) % note the absence of semicolon
The output for this example looks like:
Type: 'QAM Demodulator'
M: 32
PhaseOffset: 0
Constellation: [1x32 double]
SymbolOrder: 'Binary'
SymbolMapping: [1x32 double]
OutputType: 'Integer'
DecisionType: 'Hard decision'The MSK, OQPSK, and DPSK modem objects (i.e., only those with memory) have a reset method that resets the internal states of the object.
It assumes that the number of channels of the input signal to the modulate or demodulate methods are one (i.e., the input is a column vector).
reset(h,nchan) resets the internal states of the object, h, assuming nchan number of channels, where the input to the modulator is a matrix of nchan columns. If the modulate or demodulate method is called with an input with number of channels different from nchan, the object automatically resets itself with the correct number of channels.
The following is an example of using reset:
h = modem.mskmod; % create an object with default properties
x = randint(100, 1, 2); % generate input bits
y = modulate(h, x); % modulate x
x = randint(100, 1, 2); % generate new input bits
reset(h); % reset the modulator
y = modulate(h, x); % modulate x with the same initial state
% as the first callThe basic procedure for modulating a signal with DPSK, MSK, OQPSK, PAM, PSK, QAM, or general QAM involves these steps:
Construct a modulator object as shown in Constructing a Modem Object, depending on your modulation type.
Adjust properties of the modulator object, if necessary, to tailor it to your needs. For example, you can change the phase offset or symbol order.
Modulate your signal by applying the modulate method of the modulator object, as described in the following section.
Modulator objects have a method modulate that is used to modulate signals.
The syntax is y = modulate(h, x), where h is the handle to a modulator object and x is a signal. This syntax outputs the baseband signal y.
x can be a multichannel signal. The columns of x are considered individual channels, while the rows are time steps.
When mapping input bits to symbols, the first bit is interpreted as the most significant bit.
For h.inputtype = ‘bit' (i.e., x represents
binary input), nBits consecutive elements in
each channel or column represent a symbol, where nBits =
log2(h.M). The number of
elements in each channel must be an integer multiple of nBits,
and elements of x must be 0 or 1. For an input x of
size
, an output y of
size
is computed.
For h.inputtype = ‘integer' (i.e., x represents
symbol input), elements of x must be in the range
[0, h.M-1]. For an input x of
size
, an output y of
size
is computed.
The basic procedure for demodulating a signal with DPSK, MSK, OQPSK, PAM, PSK, QAM, or general QAM involves these steps:
Construct a demodulator object as shown in Constructing a Modem Object, depending on your modulation type.
Adjust properties of the demodulator object, if necessary, to tailor it to your needs. For example, you can change the phase offset or symbol order.
Demodulate your signal by applying the demodulate method of the demodulator object, as described in the following section.
Demodulator objects have a method demodulate that is used to demodulate signals.
The syntax is y = demodulate(h, x), where h is the handle to a demodulator object and x is a signal. This syntax processes the binary words (bits) or symbols (integers) in signal x with the PSK or QAM demodulator object and output the baseband signal y.
x can be a multichannel signal. The columns of x are considered individual channels, while the rows are time steps.
The demodulator object's property DecisionType should be set depending on whether you want hard or soft (LLR or approximate LLR) decisions. To allow for soft decisions, the demodulator object's property OutputType must be set to 'bit'.
For h.outputtype = ‘bit', an
output y of size
is computed for
an input x of size
, where nBits =
log2(h.M).
For h.outputtype = ‘integer',
an output y of size
is computed for
an input x of size
.
This code briefly illustrates the steps in modulation and demodulation.
x = randint(10,1,8); % Create a signal source.
h = modem.qammod(8) % Create a modulator object
% and display its properties.
y = modulate(h,x); % Modulate the signal x.
g = modem.qamdemod(h) % Create a demodulator object
% from a modem.qammod object
% and display its properties.
z = demodulate(g,y); % Demodulate the signal y. The log-likelihood ratio (LLR) is the logarithm of the ratio of probabilities of a 0 bit being transmitted versus a 1 bit being transmitted for a received signal. The LLR for a bit b is defined as:
![]()
Assuming equal probability for all symbols, the LLR for an AWGN channel can be expressed as:

where the variables represent the values shown in the following table.
| Variable | What the Variable Represents |
|---|---|
| Received signal with coordinates (x, y). |
| Transmitted bit (one of the K bits in an M-ary symbol, assuming all M symbols are equally probable. |
| Ideal symbols or constellation points with bit 0, at the given bit position. |
| Ideal symbols or constellation points with bit 1, at the given bit position. |
| In-phase coordinate of ideal symbol or constellation point. |
| Quadrature coordinate of ideal symbol or constellation point. |
| Noise variance of baseband signal. |
| Noise variance along in-phase axis. |
| Noise variance along quadrature axis. |
Note
Noise components along the in-phase and quadrature axes are
assumed to be independent and of equal power (i.e.,
|
Approximate LLR [4] is computed by taking into consideration only the nearest constellation point to the received signal with a 0 (or 1) at that bit position, rather than all the constellation points as done in exact LLR. It is defined as:
![]()
![]() | Digital Modulation | Selected Bibliography for Modulation | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |