-
Notifications
You must be signed in to change notification settings - Fork 20
/
MetricIZF.m
136 lines (130 loc) · 2.71 KB
/
MetricIZF.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
clear; close all; clc;
K=20;
M=400;
N=1000;
MI=zeros(4,7);
m=1;
t=10; %公式10求均值的循环次数
s=1;
for SNR=-20:5:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px]=GenPNoQ(SNR,K,M,N,5);
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;
s=1;
for SNR=-20:5:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px]=GenP(SNR,K,M,N,5);
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;
s=1;
for SNR=-20:5:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px]=GenPNoQ(SNR,K,M,N,3);
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;
s=1;
for SNR=-20:5:10
temp=0;
for h=1:t
I=0;
jj=0;
pxk=zeros(1,4);
[p,px]=GenP(SNR,K,M,N,3);
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
%画图程序
hf = figure;
set( hf, 'color', 'white');
SNR=-20:5:10;
plot( SNR, MI(1,:), '-rs','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,:), '--bo','LineWidth',1.5);
set(hf,'position',[0,0,760,468])
grid on;
legend('Full CSI,no quantizer','Full CSI,quantizer','Channel estimation,no quantizer','Channel estimation,quantizer')
xlabel('\fontsize{14}SNR(dB)');
ylabel('\fontsize{14}Mutual information per user (bit/channel use)');