%% Incorporating Gray Coding
% This example,aims to solve the following
% problem:
% Modify the modulation example (COMMDOC_MOD) so that it uses
% a Gray-coded signal constellation.
%% Setup
% Define parameters.
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
%% Signal Source
% Create a binary data stream as a column vector.
x = randint(n,1); % Random binary data stream
%% Bit-to-Symbol Mapping
% Convert the bits in x into k-bit symbols, using
% Gray coding.
% A. Define a vector for mapping bits to symbols using
% Gray coding. The vector is specific to the arrangement
% of points in a 16-QAM constellation.
mapping = [0 1 3 2 4 5 7 6 12 13 15 14 8 9 11 10].';
% B. Do ordinary binary-to-decimal mapping.
xsym = bi2de(reshape(x,k,length(x)/k).','left-msb');
% C. Map from binary coding to Gray coding.
xsym = mapping(xsym+1);
%% Modulation
% Modulate using 16-QAM.
y = modulate(modem.qammod(M),xsym);
%% 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 off;
%% Demodulation
% Demodulate signal using 16-QAM.
zsym = demodulate(modem.qamdemod(M),yrx);
%% Symbol-to-Bit Mapping
% Undo the bit-to-symbol mapping performed earlier.
% A. Define a vector that inverts the mapping operation.
[dummy demapping] = sort(mapping);
% Initially, demapping has values between 1 and M.
% Subtract 1 to obtain values between 0 and M-1.
demapping = demapping - 1;
% B. Map between Gray and binary coding.
zsym = demapping(zsym+1);
% C. Do ordinary decimal-to-binary mapping.
z = de2bi(zsym,'left-msb');
% Convert z from a matrix to a vector.
z = reshape(z.',prod(size(z)),1);
%% BER Computation
% Compare x and z to obtain the number of errors and
% the bit error rate.
[number_of_errors,bit_error_rate] = biterr(x,z)
gary_code.rar_MOD_coded modulation _gary
版权申诉
129 浏览量
2022-07-14
07:03:48
上传
评论
收藏 1KB RAR 举报
刘良运
- 粉丝: 66
- 资源: 1万+
最新资源
- 基于 Java的班级管理系统课程设计
- 深入探索Suno AI:教程、元标签与案例分析.pdf
- 超市会员积分管理系统主要用于实现了企业管理数据统计等
- 基于 Java的班级管理系统
- MyBatis 动态 SQL:灵活而强大的查询构建器.pdf
- com.accordion.prettyo.apk
- 毕业设计:基于SSM的mysql-ssm软件bug管理系统(源码 + 数据库 + 说明文档)
- MTSQL8.0.35windows(64bit)-mysql-installer-community-8.0.35.0
- 人工智能引领音乐创作新时代之Suno AI
- Public-bicycle-usage-forecast-master.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈