M = 16;                     % Size of signal constellation
k = log2(M);                % Number of bits per symbol
n = 30000;                  % Number of bits to process
numSamplesPerSymbol = 1;    % Oversampling factor
rng default                 % Use default random number generator
dataIn = randi([0 1],n,1);  % Generate vector of binary data
% stem(dataIn(1:40),'filled');
% title('Random Bits');
% xlabel('Bit Index');
% ylabel('Binary Value');
dataInMatrix = reshape(dataIn,length(dataIn)/4,4);   % Reshape data into binary 4-tuples
dataSymbolsIn = bi2de(dataInMatrix);                 % Convert to integers
% figure; % Create new figure window.
% stem(dataSymbolsIn(1:10));
% title('Random Symbols');
% xlabel('Symbol Index');
% ylabel('Integer Value');
dataMod = qammod(dataSymbolsIn,M,0);         % Binary coding, phase offset = 0
dataModG = qammod(dataSymbolsIn,M,0,'gray'); % Gray coding, phase offset = 0
