| Communications Toolbox | ![]() |
This section contains examples that illustrate how to use the digital modulation and demodulation functions.
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 = randint(5000,1,M); % Message signal % Use 16-QAM modulation. y = qammod(x,M); % Transmit signal through an AWGN channel. ynoisy = awgn(y,15,'measured'); % Create scatter plot from noisy data. scatterplot(ynoisy); % Demodulate to recover the message. z = qamdemod(ynoisy,M); % Check symbol error rate. [num,rt]= symerr(x,z)
The output and scatter plot are below. Your numerical results and plot might vary, because the example uses random numbers.
num =
83
rt =
0.0166

Notice that the scatter plot does not look exactly like a signal constellation. Whereas the signal constellation would have 16 precisely located points, the noise causes the scatter plot to have a small cluster of points approximately where each constellation point would be.
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 = randint(5000,1,M); % Message signal Nsamp = 4; % Oversampling rate % Use 16-QAM modulation. y = qammod(x,M); % 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 = qamdemod(ydownsamp,M);
| Baseband Modulated Signals Defined | Plotting Signal Constellations | ![]() |
© 1994-2005 The MathWorks, Inc.