forked from Trenson/MIMO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMetricI2.m
156 lines (151 loc) · 3.27 KB
/
MetricI2.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
clear; close all; clc;
K=20;
M=400;
N=100;
MI=zeros(8,19);
m=1;
t=1; %公式10求均值的循环次数
for method=4:5
s=1;
for SNR=-20:5/3:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px,A,y ]=GenP(SNR,K,M,N,method);
for k=1:4
for kk=1:4
pxk(k)=pxk(k)+p(4*(kk-1)+k)*px(kk);
end
end
for j=1:16
if(p(j)>0&&pxk(j-4*jj)>0)
I=I+p(j)*px(fix(j/4.1)+1)*log(p(j)/pxk(j-4*jj))/log(2);
end
if(mod(j,4)==0)
jj=jj+1;
end
end
temp=temp+I;
end
MI(m,s)=temp/t; % m表示图2的某条线
s=s+1; % s表示横轴的第几个值
end
m=m+1;
end
%N=50K
for method=2:3
s=1;
for SNR=-20:5/3:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px,A,y ]=GenP(SNR,K,M,N*10,method);
for k=1:4
for kk=1:4
pxk(k)=pxk(k)+p(4*(kk-1)+k)*px(kk);
end
end
for j=1:16
if(p(j)>0)
I=I+p(j)*px(fix(j/4.1)+1)*log(p(j)/pxk(j-4*jj))/log(2);
end
if(mod(j,4)==0)
jj=jj+1;
end
end
temp=temp+I;
end
MI(m,s)=temp/t;
s=s+1;
end
m=m+1;
end
%N=10K
for method=2:3
s=1;
for SNR=-20:5/3:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px,A,y ]=GenP(SNR,K,M,N*2,method);
for k=1:4
for kk=1:4
pxk(k)=pxk(k)+p(4*(kk-1)+k)*px(kk);
end
end
for j=1:16
if(p(j)>0)
I=I+p(j)*px(fix(j/4.1)+1)*log(p(j)/pxk(j-4*jj))/log(2);
end
if(mod(j,4)==0)
jj=jj+1;
end
end
temp=temp+I;
end
MI(m,s)=temp/t;
s=s+1;
end
m=m+1;
end
%N=5K
for method=2:3
s=1;
for SNR=-20:5/3:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px,A,y ]=GenP(SNR,K,M,N,method);
for k=1:4
for kk=1:4
pxk(k)=pxk(k)+p(4*(kk-1)+k)*px(kk);
end
end
for j=1:16
if(p(j)>0)
I=I+p(j)*px(fix(j/4.1)+1)*log(p(j)/pxk(j-4*jj))/log(2);
end
if(mod(j,4)==0)
jj=jj+1;
end
end
temp=temp+I;
end
MI(m,s)=temp/t;
s=s+1;
end
m=m+1;
end
%MI = MI*2; % 08.06加
%画图程序
hf = figure;
set( hf, 'color', 'white');
SNR=-20:5/3:10;
plot( SNR, MI(1,:), '-bo','LineWidth',1.5);
hold on;
plot( SNR, MI(2,:), '-rs','LineWidth',1.5);
hold on;
plot( SNR, MI(3,:), '--bo','LineWidth',1.5);
hold on;
plot( SNR, MI(4,:), '--rs','LineWidth',1.5);
hold on;
plot( SNR, MI(5,:), ':bo','LineWidth',1.5);
hold on;
plot( SNR, MI(6,:), ':rs','LineWidth',1.5);
hold on;
plot( SNR, MI(7,:), '-.bo','LineWidth',1.5);
hold on;
plot( SNR, MI(8,:), '-.rs','LineWidth',1.5);
set(hf,'position',[0,0,760,468])
grid on;
legend('MRC,full CSI','ZF,full CSI','MRC,channel estimation,N=50K','ZF,channel estimation,N=50K','MRC,channel estimation,N=10K','ZF,channel estimation,N=10K','MRC,channel estimation,N=5K','ZF,channel estimation,N=5K')
xlabel('\fontsize{14}SNR(dB)');
ylabel('\fontsize{14}Mutual information per user (bit/channel use)');