wozaimoyu
/
IRS_Enhanced-Wireless-Network_Joint-Active-and-Passive-BeamformingDesign_Qingqing-Wu-and-Rui-Zhang
Public
forked from jhan-04/IRS_Enhanced-Wireless-Network_Joint-Active-and-Passive-BeamformingDesign_Qingqing-Wu-and-Rui-Zhang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUntitled3.m
88 lines (58 loc) · 1.27 KB
/
Untitled3.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
%funtion of distributed algorithm333
clc
clear all
N=50;
d=50;
for c=1:1000
P=10^(5/10)/1000;%5dBm
P_noise=10^(-80/10)/1000;%-80dBm
M=8;
d0=51;
dv=2;
Hr_H=(randn(1,N)+1i*randn(1,N))/sqrt(2);%Rayleigh
Hd_H=(randn(1,M)+1i*randn(1,M))/sqrt(2);%Rayleigh
% for i=1:N
% Hr_H(1,i)=1/sqrt(2)+1i/sqrt(2);
% end
%
% for i=1:M
% Hd_H(1,i)=1/sqrt(2)+1i/sqrt(2);
% end
%
kdb=1000;
k=10^(kdb/10);
g=sqrt(k/(k+1))+sqrt(1/(k+1)).*(randn(1,M)+1i*randn(1,M))/sqrt(2);%Rician
for j=1:N
g2=g.*sqrt(10^(-3).*10^(5/10).*d0^-2.2);
G(j,:)=g2;
end
d_hr=sqrt((d0-d)^2+dv^2);%d2
d_hd=sqrt(d^2+dv^2);%d1
hr_H=Hr_H.*sqrt(10^(-3).*10^(-10/10).*10^(5/10).*d_hr^-3);
hr=hr_H';
hd_H=Hd_H.*sqrt(10^(-3).*10^(-10/10).*d_hd^-3);
hd=hd_H';
k=1;
w_k=sqrt(P).*hd/norm(hd);
eps=10^(-4);
value=100;
value_new=1;
while abs(value-value_new)>eps
Phase0=angle(hd_H*w_k);
for n=1:1:N
th_k(n)=Phase0-angle(hr_H(n))-angle(G(n,:)*w_k);%1XN
end
v_H=exp(1i.*th_k);
v=v_H';
%Theta=diag(v_H)
w_MRT=sqrt(P).*(hr_H*diag(v_H)*G+hd_H)'/norm(hr_H*diag(v_H)*G+hd_H);
a=-angle(hd_H*w_MRT);
w_k=w_MRT.*exp(a);
value=value_new;
value_new=(abs((hr_H*diag(v_H)*G+hd_H)*w_k))^2;
value_new_2=(abs((hr_H*diag(v_H)*G)*w_k)+abs((hd_H)*w_k))^2;
k=k+1;
end
SNR_c(c)=10*log10(value_new/P_noise);
end
SNR=mean(SNR_c);