Code covered by the BSD License  

Highlights from
bit to symbol mapping

bit to symbol mapping

by

 

The program converts the bits in x into k-bit symbols.

bit_to_symbol_mapping.m
%% Bit-to-Symbol Mapping
% Convert the bits in x into k-bit symbols.
M = 16; % Size of signal constellation
k = log2(M); % Number of bits per symbol
n = 3e4; % Number of bits to process
nsamp = 1; % Oversampling rate
x = randint(n,1); % Random binary data stream
xsym = bi2de(reshape(x,k,length(x)/k).','left-msb');

%% Stem Plot of Symbols 
% Plot first 10 symbols in a stem plot.
figure; % Create new figure window.
stem(xsym(1:10));  %stem=discrete value
title('Random Symbols');
xlabel('Symbol Index'); ylabel('Integer Value');
%% Modulation
y = modulate(modem.qammod(M),xsym); % Modulate using 16-QAM.

%% Transmitted Signal
ytx = y;

%% Channel
% Send signal over an AWGN channel.
EbNo = 10; % In dB
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
ynoisy = awgn(ytx,snr,'measured');

%% Received Signal
yrx = ynoisy;
%% Scatter Plot
% Create scatter plot of noisy signal and transmitted
% signal on the same axes.
h = scatterplot(yrx(1:nsamp*5e3),nsamp,0,'g.');
hold on;
scatterplot(ytx(1:5e3),1,0,'k*',h);
title('Received Signal');
legend('Received Signal','Signal Constellation');
axis([-5 5 -5 5]); % Set axis ranges.
hold on;




Contact us