Communications Toolbox | ![]() ![]() |
Simple Digital Modulation Example
This example illustrates the basic format of the baseband modulation and demodulation commands, dmodce
and ddemodce
. Although the example uses the PSK method, most elements of this example apply to digital modulation techniques other than PSK.
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. The ddemodce
function demodulates the analog signal y
and then demaps to produce the digital signal z
.
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. However, the noise is sufficiently small that the signal can be recovered perfectly.
Note Because some options vary by method, you should check the reference pages before adapting the code here for other uses. |
Below are the code and the scatter plot.
M = 16; % Use 16-ary modulation. Fd = 1; % Assume the original message is sampled % at a rate of 1 sample per second. Fs = 3; % The modulated signal will be sampled % at a rate of 3 samples per second. x = randint(100,1,M); % Random digital message % Use M-ary PSK modulation to produce y. y = dmodce(x,Fd,Fs,'psk',M); % Add some Gaussian noise. ynoisy = y + .04*randn(300,1) + .04*j*randn(300,1); % Create scatter plot from noisy data. scatterplot(ynoisy,1,0,'b.'); % Demodulate y to recover the message. z = ddemodce(ynoisy,Fd,Fs,'psk',M); s = symerr(x,z) % Check symbol error rate. s = 0
![]() | Representing Signal Constellations | Customizing the Modulation Process | ![]() |