Products & Services Industries Academia Support User Community Company

Learn more about Communications Toolbox   

Digital Modulation

Section Overview

Like analog modulation, digital modulation alters a transmittable signal according to the information in a message signal. However, in this case, the message signal is restricted to a finite set. Using this toolbox, you can modulate or demodulate signals using various digital modulation techniques, listed in Modulation Features of the Toolbox. You can also plot signal constellations. Modulation functions output the complex envelope of the modulated signal.

Representing Digital Signals

To modulate a signal using digital modulation with an alphabet having M symbols, start with a real message signal whose values are integers from 0 to M-1. Represent the signal by listing its values in a vector, x. Alternatively, you can use a matrix to represent a multichannel signal, where each column of the matrix represents one channel.

For example, if the modulation uses an alphabet with eight symbols, then the vector [2 3 7 1 0 5 5 2 6]' is a valid single-channel input to the modulator. As a multichannel example, the two-column matrix

[2 3;
 3 3;
 7 3;
 0 3;]

defines a two-channel signal in which the second channel has a constant value of 3.

Baseband Modulated Signals Defined

If you use baseband modulation to produce the complex envelope y of the modulation of a message signal x, then y is a complex-valued signal that is related to the output of a passband modulator. If the modulated signal has the waveform

where fc is the carrier frequency and θ is the carrier signal's initial phase, then a baseband simulation recognizes that this equals the real part of

and models only the part inside the square brackets. Here j is the square root of -1. The complex vector y is a sampling of the complex signal

If you prefer to work with passband signals instead of baseband signals, then you can build functions that convert between the two. Be aware that passband modulation tends to be more computationally intensive than baseband modulation because the carrier signal typically needs to be sampled at a high rate.

Gray Encoding a Modulated Signal

For the PSK, DPSK, FSK, QAM, and PAM modulation types, Gray constellations are obtained by selecting the Gray parameter in the corresponding modulation function or method.

For modulation objects, you can set the symbol order property to Gray to obtain Gray-encoded modulation.

The following example demonstrates use of the symbol order property. The Scatter plot shows the modulated symbols are Gray-encoded.

% Create 8-PSK Gray encoded modulator
hMod = modem.pskmod('M',8,'SymbolOrder','Gray');
% Create a scatter plot
scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1,...
    'Constellation',hMod.Constellation);
% Show constellation
scatterPlot.PlotSettings.Constellation = 'on';
scatterPlot.PlotSettings.ConstellationStyle = 'rd';
% Add symbol labels
hold on;
k=log2(hMod.M);
for jj=1:hMod.M
        text(real(hMod.Constellation(jj))-0.15,imag(hMod.Constellation(jj))+0.15,...
        dec2base(hMod.SymbolMapping(jj),2,k));
end
hold off;

For modulation functions, set the symbol order argument to Gray.

Looking at the map above, notice that this is indeed a Gray-encoded map; all adjacent elements differ by only one bit.

Examples of Digital Modulation and Demodulation

This section contains examples that illustrate how to use the digital modulation and demodulation functions.

Computing the Symbol Error Rate

The example generates a random digital signal, modulates it, and adds noise. Then it creates a scatter plot, demodulates the noisy signal, and computes the symbol error rate. For a more elaborate example that is similar to this one, see Modulating a Random Signal.

% Create a random digital message
M = 16;                     % Alphabet size
x = randi([0 M-1],5000,1);  % Random symbols

% Use 16-QAM modulation.
hMod = modem.qammod(M);
hDemod = modem.qamdemod(hMod);

% Create a scatter plot and show constellation
scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1,...
    'Constellation',hMod.Constellation);
scatterPlot.PlotSettings.Constellation = 'on';

% Modulate
y = modulate(hMod,x);

% Transmit signal through an AWGN channel.
ynoisy = awgn(y,15,'measured');

% Create scatter plot from noisy data.
update(scatterPlot,ynoisy);

% Demodulate ynoisy to recover the message.
z=demodulate(hDemod,ynoisy);

% Check symbol error rate.
[num,rt] = symerr(x,z)

The output and scatter plot follow. Your numerical results and plot might vary, because the example uses random numbers.

num =

    83


rt =

    0.0166

The scatter plot does not look exactly like a signal constellation. Where the signal constellation has 16 precisely located points, the noise causes the scatter plot to have a small cluster of points approximately where each constellation point would be.

Combining Pulse Shaping and Filtering with Modulation

Modulation is often followed by pulse shaping, and demodulation is often preceded by a filtering or an integrate-and-dump operation. This section presents an example involving rectangular pulse shaping. For an example that uses raised cosine pulse shaping, see Pulse Shaping Using a Raised Cosine Filter.

Rectangular Pulse Shaping.   Rectangular pulse shaping repeats each output from the modulator a fixed number of times to create an upsampled signal. Rectangular pulse shaping can be a first step or an exploratory step in algorithm development, though it is less realistic than other kinds of pulse shaping. If the transmitter upsamples the modulated signal, then the receiver should downsample the received signal before demodulating. The "integrate and dump" operation is one way to downsample the received signal.

The code below uses the rectpulse function for rectangular pulse shaping at the transmitter and the intdump function for downsampling at the receiver.

M = 16;                     % Alphabet size
x = randi([0 M-1],5000,1);  % Message signal
Nsamp = 4;                  % Oversampling rate

% Use 16-QAM modulation.
hMod = modem.qammod(M);
hDemod = modem.qamdemod(hMod);

% Modulate
y = modulate(hMod,x);

% Follow with rectangular pulse shaping.
ypulse = rectpulse(y,Nsamp);

% Transmit signal through an AWGN channel.
ynoisy = awgn(ypulse,15,'measured');

% Downsample at the receiver.
ydownsamp = intdump(ynoisy,Nsamp);

% Demodulate to recover the message.
z = demodulate(hDemod,ydownsamp);

Plotting Signal Constellations

To plot the signal constellation associated with a modulation process, follow these steps:

  1. If the alphabet size for the modulation process is M, then create the signal [0:M-1]. This signal represents all possible inputs to the modulator.

  2. Use the appropriate modulation function to modulate this signal. If desired, scale the output. The result is the set of all points of the signal constellation.

  3. Apply the scatterplot function to the modulated output to create a plot.

Examples of Signal Constellation Plots

The following examples produce plots of signal constellations:

The reference entries for the modnorm and genqammod functions provide additional examples.

Constellation for 16-PSK.  

The code below plots a PSK constellation having 16 points.

% Use 16-PSK modulation.
hMod = modem.pskmod(16);

% Create a scatter plot
scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1,...
    'Constellation',hMod.Constellation);
% Show constellation
scatterPlot.PlotSettings.Constellation = 'on';
scatterPlot.PlotSettings.ConstellationStyle = 'rd';
% Add symbol labels
hold on;
k=log2(hMod.M);
for jj=1:hMod.M
        text(real(hMod.Constellation(jj))-0.15,...,
        imag(hMod.Constellation(jj))+0.15,...
        dec2base(hMod.SymbolMapping(jj),2,k));
end
hold off;

Constellation for 32-QAM.  

The code below plots a QAM constellation having 32 points and a peak power of 1 watt. The example also illustrates how to label the plot with the numbers that form the input to the modulator.

% Create 32-QAM modulator
hMod = modem.qammod(32);
% Create a scatter plot
scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1,...
    'Constellation',hMod.Constellation);
% Show constellation
scatterPlot.PlotSettings.Constellation = 'on';
scatterPlot.PlotSettings.ConstellationStyle = 'rd';
% Add symbol labels
hold on;
for jj=1:hMod.M
   text(real(hMod.Constellation(jj)),imag(hMod.Constellation(jj)),...
   [' ' num2str(hMod.SymbolMapping(jj))]);
end
hold off;

Gray-Coded Signal Constellation.  

The example below plots an 8-QAM signal Gray-coded constellation, labeling the points using binary numbers so you can verify visually that the constellation uses Gray coding.

% Create 8-QAM Gray encoded modulator
hMod = modem.qammod('M',8,'SymbolOrder','Gray');
% Create a scatter plot
scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1,...
    'Constellation',hMod.Constellation);
% Show constellation
scatterPlot.PlotSettings.Constellation = 'on';
scatterPlot.PlotSettings.ConstellationStyle = '.';
% Add symbol labels
hold on;
k=log2(hMod.M);
for jj=1:hMod.M
        text(real(hMod.Constellation(jj))+0.15,...,
        imag(hMod.Constellation(jj)),...
        dec2base(hMod.SymbolMapping(jj),2,k));
end
hold off;

Customized Constellation for QAM.   The code below describes and plots a constellation with a customized structure.

% Describe constellation.
inphase = [1/2 -1/2 1 0 3/2 -3/2 1 -1];
quadr = [1 1 0 2 1 1 2 2];
inphase = [inphase; -inphase]; inphase = inphase(:);
quadr = [quadr; -quadr]; quadr = quadr(:);
const = inphase + 1i*quadr;

% Create a scatter plot
scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1,...
    'Constellation',const);
% Show constellation
scatterPlot.PlotSettings.Constellation = 'on';
scatterPlot.PlotSettings.ConstellationStyle = '*';
title('Customized Constellation for QAM');

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS