clc
clear all
close all
%% Modulation Oreder
M = 16 ;
%% Create Random data
data = randi([0 M-1] , 100 , 1 ) ;
%% Modulator
hModulator = comm.PAMModulator('ModulationOrder' , M , 'BitInput' , false , 'SymbolMapping' , 'gray' , ...
    'MinimumDistance' , 4) ;
modData = step(hModulator  , data ) ;
%% AWGN Channel
SNRPAM = 10;
hAWGN = comm.AWGNChannel ( 'NoiseMethod' , 'Signal to noise ratio (SNR)' , 'SNR' , SNRPAM , 'SignalPower' , 10 );
%% 
awData  = step(hAWGN , modData ) ;
%% Demodulator
hDemodulator = comm.PAMDemodulator ('ModulationOrder' , M , 'SymbolMapping' , 'gray' , ...
    'MinimumDistance' , 2) ;
%% 
rwData  = step( hDemodulator , awData )  ; 
%% plot
constellation(hModulator);
hold on
plot(real(awData) , imag(awData),' b*')