%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% All rights reserved by Krishna Pillai, http://www.dsplog.com
% The file may not be re-distributed without explicit authorization
% from Krishna Pillai.
% Checked for proper operation with Octave Version 3.0.0
% Author : Krishna Pillai
% Email : krishna@dsplog.com
% Version : 1.0
% Date : 17 May 2008
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bit Error Rate for 16-PSK modulation using Gray modulation mapping
clear
N = 10^5; % number of symbols
M = 8; % constellation size
k = log2(M); % bits per symbol
thetaMpsk = [0:M-1]*2*pi/M; % reference phase values
Eb_N0_dB = [0:25]; % multiple Es/N0 values
Es_N0_dB = Eb_N0_dB + 10*log10(k);
% Mapping for binary <--> Gray code conversion
ref = [0:M-1];
map = bitxor(ref,floor(ref/2));
[tt ind] = sort(map);
ipPhaseHat = zeros(1,N);
for ii = 1:length(Eb_N0_dB)
% symbol generation
% ------------------
ipBit = rand(1,N*k,1)>0.5; % random 1's and 0's
bin2DecMatrix = ones(N,1)*(2.^[(k-1):-1:0]) ; % conversion from binary to decimal
ipBitReshape = reshape(ipBit,k,N).'; % grouping to N symbols having k bits each
ipGray = [sum(ipBitReshape.*bin2DecMatrix,2)].'; % decimal to binary
% Gray coded constellation mapping
ipDec = ind(ipGray+1)-1; % bit group to constellation point
ipPhase = ipDec*2*pi/M; % conversion to phase
ip = exp(j*ipPhase); % modulation
s = ip;
% noise
% -----
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white guassian noise, 0dB variance
y = s + 10^(-Es_N0_dB(ii)/20)*n; % additive white gaussian noise
% demodulation
% ------------
% finding the phase from [-pi to +pi]
opPhase = angle(y);
% unwrapping the phase i.e. phase less than 0 are
% added 2pi
opPhase(find(opPhase<0)) = opPhase(find(opPhase<0)) + 2*pi;
% rounding the received phase to the closest constellation
ipPhaseHat = 2*pi/M*round(opPhase/(2*pi/M)) ;
% as there is phase ambiguity for phase = 0 and 2*pi,
% changing all phases reported as 2*pi to 0.
% this is to enable comparison with the transmitted phase
ipPhaseHat(find(ipPhaseHat==2*pi)) = 0;
ipDecHat = round(ipPhaseHat*M/(2*pi));
% Decimal to Gray code conversion
ipGrayHat = map(ipDecHat+1); % converting to decimal
ipBinHat = dec2bin(ipGrayHat,k) ; % decimal to binary
% converting binary string to number
ipBinHat = ipBinHat.';
ipBinHat = ipBinHat(1:end).';
ipBinHat = str2num(ipBinHat).' ;
% counting errors
nBitErr(ii) = size(find([ipBit- ipBinHat]),2); % couting the number of errors
end
simBer = nBitErr/(N*k);
theoryBer = (1/k)*erfc(sqrt(k*10.^(Eb_N0_dB/10))*sin(pi/M));
close all; figure
semilogy(Eb_N0_dB,theoryBer,'bs-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);
axis([0 20 10^-5 1])
grid on
legend('theory', 'simulation');
xlabel('Eb/No, dB')
ylabel('Bit Error Rate')
title('Bit error probability curve for 16-PSK modulation')
matlab_演示用于调制16PSK
版权申诉
5星 · 超过95%的资源 98 浏览量
2022-06-20
11:37:29
上传
评论
收藏 2KB ZIP 举报
wouderw
- 粉丝: 286
- 资源: 2961
最新资源
- SM4-CFB代码实现及基本补位示例代码
- 基于asp的搜索引擎开发(源代码)
- Java课设相关材料.zip
- JSP搜索引擎的研究与实现(源代码)
- delphi 12 控件之delphipi.0.85.setup.exe
- 数据库管理工具:dbeaver-ce-23.0.2-amd64.deb
- 搜索链接淘特搜索引擎共享版-tot-search-engine
- 数据库管理工具:dbeaver-ce-24.0.3-macos-x86-64.dmg
- 数据库管理工具:dbeaver-ce-24.0.1-x86-64-setup.exe
- GoogleCloud2024年数据和AI趋势报告+生成式AI+数据治理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈