-
Notifications
You must be signed in to change notification settings - Fork 4
/
MPSK_NAKAGAMI.m
161 lines (123 loc) · 5.19 KB
/
MPSK_NAKAGAMI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
function pe = MPSK_NAKAGAMI(M)
% ========================================================================================================================
% BIT ERROR PROBABILITY OF M-PSK OVER NAKAGAMI FADING CHANNEL SUBJECTED TO DOUBLE GATED NOISE
% The Bit Error Probability of M-PSK scheme is obtained by a formula where
% Error Function erfc can be obtained by 2-(2*CDF(Additive Noise)) then by
% Multiplying it with weights W(i,k,M) followed by summation with i and k
% Hence CDF of Additive noise is obtained and called into the main function
% Probability of Error is validated with respect to
snr_db = linspace(0,30,30);
% BER of M-PSK scheme
final_count = 0;
for k = 1:log2(M/2)
count = 0;
i = 0:1:(((1-2.^(-k))*(M/2))-1);
for i_len = 1:length(i)
% Weights w(i,k,M) is defined as
W = ((-1).^(floor((i(i_len).*(2.^(k-1)))/(M/2)))).*((2.^(k-1))-(floor(((i(i_len).*(2.^(k-1)))/(M/2))+0.5)));
% a(i,M) is defined as
a = (4.*(((2.*i(i_len))+1).^2).*log2(M).*((sin(((2.*i(i_len))+1)*(pi/M))).^2));
% Error Function for M-PSK scheme is defined as
erfc = 2-(2.*CDF(a));
% Validating inner Summation
count = count + (W.*erfc);
end % for i_len
% Validating Outer Summation
final_count = final_count + count;
end % for k
% PROBABILITY OF ERROR OVER M-PSK SCHEME
pe = abs((1/((M/2).*log2(sqrt(M/2)))).*final_count);
% ----------------- Plotting BER vs SNR ------------------------------------
figure(2), clf
semilogy(snr_db,pe(1,:),'->b',...
snr_db,pe(2,:),'-->r',...
snr_db,pe(3,:),'-.>g',...
snr_db,pe(4,:),':>k',...
'LineWidth',2);
xlim([0 25])
set(gcf,'color','white')
xlabel('Signal to Noise Ratio (dB)','FontSize',16)
ylabel('Bit Error Probability (Pe)','FontSize',16)
title('BEP of M-PSK over Nakagami Fading Channel subjected to Double Gated Noise','FontSize',16)
legend({'SNI(dB)=10, m=1.5',...
'SNI(dB)=15, m=1.5',...
'SNI(dB)=20, m=1.5',...
'SNI(dB)=25, m=1.5'},...
'FontSize',16,'Location','southwest');
legend('boxoff')
% ---------------------- End of Plotting -----------------------------------
% =========================================================================================================================
function final = CDF(A)
% =========================================================================================================================
% CUMMULATIVE DISTRIBUTION FUNCTION OF ADDITIVE NOISE F(r)
% The CDF of Additive noise is obtained by normalizing and finding
% Cummulative summation of PDF of Additive Noise
% PDF of Additive Noise is obtained by integrating the product of
% The PDF's of NAKAGAMI-m fading model and G2AWGN noise model
% Nakagami Fading Parameter
m = 1.5;
% Average Power Transmitted
Ohm = 1.0;
% AWGN variables
alpha = 0.5;
beta = 0.5;
p1 = 0.5;
p2 = 0.5;
% Considering SNR and SNI values in dB
sni_dB = [10 15 20 25];
snr_dB = linspace(0,30,30);
% Conversion of dB to normal
sni = 10.^(sni_dB/10);
snr = 10.^(snr_dB/10);
% PDF of Additive Noise
pre_final = zeros(length(snr),1);
final = zeros(length(sni),length(snr));
for sni_len = 1:length(sni)
for snr_len = 1:length(snr)
% SNR and SNI in terms of Ng and Ni respectively
Ng = 2*(snr(snr_len)^2);
Ni = 2*(sni(sni_len)^2);
% Substituting a(i,M)*Eb in r
% Eb = Ng*SNR or Eb = Ni*SNI
r = A.*Ng.*snr(snr_len);
% 1st part of equation
term1 = alpha*beta*p1*p2/sqrt(pi*(Ng+Ni));
term2 = (m/Ohm)^m;
term3 = gamma(m+0.5)/gamma(m);
term4 = ((r.^2/(Ng+Ni))+(m/Ohm)).^-(m+0.5);
head = term1.*term2.*term3.*term4;
% 2nd part of equation
term5 = (1-alpha*beta*p1*p2)/sqrt(pi*(Ng));
term6 = (m/Ohm)^m;
term7 = gamma(m+0.5)/gamma(m);
term8 = ((r.^2/(Ng))+(m/Ohm)).^-(m+0.5);
tail = term5.*term6.*term7.*term8;
% Adding 2 parts of equation
pre_final(snr_len,:) = head + tail;
% Calculating CDF of Additive Noise
P_pdf = pre_final./sum(pre_final);
P_cdf = cumsum(P_pdf);
end % for snr_len
final(sni_len,:) = P_cdf;
end % for sni_len
% ---------------- Plotting CDF of Additive Noise --------------------------
figure(1), clf
semilogy(snr_dB,final(1,:),'->b',...
snr_dB,final(2,:),'-->r',...
snr_dB,final(3,:),'-.>g',...
snr_dB,final(4,:),':>k',...
'LineWidth',2);
xlim([0 5])
set(gcf,'color','white')
xlabel('Additive Noise','FontSize',16)
title('CDF OF ADDITIVE NOISE','FontSize',16)
legend({'SNI(dB)=10, m=1.5',...
'SNI(dB)=15, m=1.5',...
'SNI(dB)=20, m=1.5',...
'SNI(dB)=25, m=1.5'},...
'FontSize',16,'Location','southwest');
legend('boxoff')
% ------------------ End of Plotting ---------------------------------------
end % function sub
% =========================================================================================================================
end % function main