📄 pr2_47.m
字号:
%Problem 2.47;
%M-ary transmission error probability;
%Calculates, plots versus SNR and compares error probabilities for uncoded
%and orthogonally encoded (exact formula and union bound) m-ary data transmission;
clear all; close all;
global Q L; %these global variables will be then used in calculating of integrand "intgr" ;
q=[1:0.1:5.5]; Nq=size(q,2); qlg=20*log10(q); %SNR per bit array and conversion to decibels;
k=input('input number of bits k='); M=2^k; L=M-1; %inputting number of bits and calculating number of messages;
P=ones(3,Nq); %template for the matrix of error probabilities: 1st row - encoded, exact; 2-d row - encoded, union bound; 3-d row - uncoded;
for s=1:Nq %in this loop all three probabilities are calculated for the range of SNR
Q=sqrt(k)*q(s); %SNR per the whole message;
P(2,s)=min([1 L*erfc(Q/2)/2]); %encoded, union bound;
if P(2,s)<=1e-4 P(1,s)=P(2,s); %there is no need to calculate an accurate probability in this case, since union bound has an excellent precision;
else P(1,s)=1-quadl(@intgr,-4,16); end; %encoded, exact probability; function "intgr" is formed by a separate m-file;
P(3,s)=1-normcdf(q(s),0,1).^k; %uncoded;
end;
semilogy(qlg,P(1,:),'r',qlg,P(2,:),'b',qlg,P(3,:),'k'); grid; xlabel('SNR per bit, dB'); ylabel('Pe'); ylim([1e-7,1]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -