Communications Toolbox    

How the Example Works

This section displays and explains the example code, piece by piece.

Setting Up Parameters

The first part of the example defines variables that the rest of the example will use. The symbol alphabet has M different symbols, namely, the integers between 0 and M-1. The message will be a column vector having len entries, each of which is chosen from the symbol alphabet.

The variables Fd and Fs refer to the relative sampling rates for the modulation scheme. They would be more meaningful if the example were sampling a real signal that had a natural notion of time. However, since this example uses a random signal that does not have a built-in notion of time, the main purpose of Fd and Fs is to indicate that the modulated signal has three entries for every one entry of the original signal.

Creating the Signal

The variable signal is a len-by-1 matrix, that is, a column vector of length len, whose entries are randomly chosen integers between 0 and M-1. This is the signal that the example will modulate. The randint function is part of this toolbox.

Modulating the Signal

This part of the example modulates the data in the column vector signal in two different ways. The dmodce function performs both modulations and puts the results into the two-column matrix modsignal.

The first call to dmodce, which creates the first column of modsignal, tells dmodce to use QASK modulation on M symbols. The string 'qask' indicates the QASK method as well as the default square constellation configuration. In this case, the configuration implements Gray code.

The second call to dmodce, which creates the second column of modsignal, tells dmodce to use QASK modulation with a signal constellation whose configuration is represented in the vectors inphase and quad. The variables inphase and quad are length-M vectors that list the in-phase and quadrature components, respectively, of the points in the signal constellation. The points are listed in sequence, to associate a message symbol of k with the (k+1)st elements in inphase and quad. Whereas Gray code labels the constellation points in a special way, this configuration lists points in a sequence that is merely convenient for creating inphase and quad.

These lines also illustrate some common ways to manipulate matrices in MATLAB. If you are not familiar with MATLAB's colon notation or with functions like ones and zeros, then you should consult the MATLAB documentation set.

Adding Noise

According to the definition of baseband QASK modulation, modsignal is a complex matrix having len*Fs/Fd rows and two columns. The command below adds normally distributed random numbers to the real and imaginary parts of modsignal, to produce a noisy signal noisy. The randn function is a built-in MATLAB function.

Notice that the command adds to modsignal an entire real matrix of the appropriate size and an entire imaginary matrix of the appropriate size. Using a loop to add noise to individual scalar entries of modsignal would be less efficient, since MATLAB is optimized for matrix operations.

Demodulating the Signal

This part of the example demodulates the noisy modulated signal, noisy, in two different ways. The ddemodce function performs both demodulations by operating on each column of noisy separately. In each case, ddemodce puts the results into the two-column matrix newsignal.

Computing and Displaying Bit Error Rates

The biterr function compares each demodulated signal (that is, each column of newsignal) to the original signal. Then biterr computes the number of bit errors, as well as the rate or fraction of bit errors. The built-in MATLAB function disp displays the two bit error rates in the command window.

Plotting a Signal Constellation

The modmap function plots and labels the default square signal constellation having M points. The constellation that inphase and quad determine looks the same, except that the points are labeled from left to right across each row in the diagram, starting with the upper row.


 Where to Find the Example Output from the Example