The MATLAB command 'scatter' plots a constellation diagram when original message symbols or demodulated symbols are in the complex number format. On the other hand, the MATLAB command 'scatterplot' is used when original message symbols or demodulated symbols are in the decimal format.
Example (use of 'scatterplot')
% Clearing workspace, closing figures, and setting seed for random number generation
clc;
clear all;
close all;
% Setting parameters
rng(10);
M = 4; % Number of phases for PSK modulation
N_Bits = 2520; % Total number of bits to transmit
Phase = 0; % Initial phase angle
% Generating random binary data
data_info_bit = randi([0,1],N_Bits,1);
% Converting binary data to decimal
data_temp = bi2de(reshape(data_info_bit,N_Bits/log2(M),log2(M)));
% Performing PSK modulation
modData = pskmod(data_temp,M,Phase);
% Visualizing modulated data
figure(1);
scatterplot(modData);
% Simulating channel with AWGN
channelAWGN = 15; % Noise power
rxData2 = awgn(modData, channelAWGN);
% Visualizing received data with noise
figure(2);
scatterplot(rxData2);
% Demodulating received data
demodData = pskdemod(rxData2,M,Phase);
Output
Fig 1: Scatter plot of original QPSK message symbols
Fig 2: Scatter plot of demodulated QPSK symbols
Example (use of 'scatter')
clc;
clear all;
close all;
% Setting parameters
rng(10);
M = 4; % Number of phases for PSK modulation
N_Bits = 2520; % Total number of bits to transmit
Phase = 0; % Initial phase angle
% Generating random binary data
data_info_bit = randi([0,1],N_Bits,1);
% Converting binary data to decimal
data_temp = bi2de(reshape(data_info_bit,N_Bits/log2(M),log2(M)));
% Performing PSK modulation
modData = pskmod(data_temp,M,Phase);
% Visualizing modulated data
figure(1);
scatter(real(modData), imag(modData));
title('Original Message Symbols');
xlabel('Real Part');
ylabel('Imaginary Part');
grid on;
% Simulating channel with AWGN
channelAWGN = 15; % Noise power
rxData2 = awgn(modData, channelAWGN);
% Visualizing received data with noise
figure(2);
scatter(real(rxData2), imag(rxData2));
title('Received Data with AWGN');
xlabel('Real Part');
ylabel('Imaginary Part');
grid on;
% Demodulating received data
demodData = pskdemod(rxData2,M,Phase);