(Source Matlab Code) Code mô phỏng hiệu năng của hệ thống theo SNR
close all; % dong tat ca cac chuong trinh khac dang chay voi matlab
clear all; % xoa tat ca cac bien duoc matlab tao khi chay cac chuong trinh truoc
do
Mantennas=25; %So luong antenna duoc dieu chinh phu hop voi tung truong hop Kusers=10; %So luong nguoi dung
PdBvar=-20:5:20; %SNR ti so cong suat tin hieu tren nhieu, don vi dB, coi P_noise=1 thi P=SNR.
monteCarloRealizations = 10000; % monteCarloRealizations la so vong lap thong ke cua he thong
for p = 1:length(PdBvar) M = Mantennas; K = Kusers; P = 10^(PdBvar(p)/10); Hfull = (randn(M,K,monteCarloRealizations)+1i*randn(M,K,monteCarloRealizations)) /sqrt(2);
% ma tran Hfull kich thuoc MxK duoc tao ra la kenh truyen giua M antenna tram goc
%va K nguoi dung. Hfull~CN(0,1).
s_real=(randn(K,1,monteCarloRealizations)+1i*randn(K,1,monteCarloRealizat ions))/sqrt(2); % vecto symbol input
57
n_real=(randn(K,1,monteCarloRealizations)+1i*randn(K,1,monteCarloRealizat ions))/sqrt(2); %nhieu Gauss ~CN(0,1) tai noi nhan.
for r = 1:monteCarloRealizations
r %khi go lenh r ma bo qua dau “;” thi gia tri r se hien thi tren man hinh H = Hfull(:,:,r); %lenh nay trich xuat ma tran kenh cua vong lap thu r trong
ma tran Hfull.
s = s_real(:,:,r); %vecto symbol input n = n_real(:,:,r); %vecto noise
MRT.A = conj(H); % ma tran MRT Precoding
MRT.beta = sqrt(trace(H.'*conj(H))./P); %tinh he so cua bo MRT theo cong thuc (3.14)
ZF.G = inv(H.'*conj(H)); %thanh phan cua ma tran ZF A ZF.A = conj(H)*ZF.G; % ma tran ZF Precoding
ZF.beta = sqrt(trace(ZF.A*ZF.A')./P); %tinh he so cua bo ZF theo cong thuc
(3.10)
MMSE.G = inv(H.'*conj(H)+K*eye(K)./P); %thanh phan cua ma tran MMSE
A
MMSE.A = conj(H)*MMSE.G; %ma tran MMSE Precoding
MMSE.beta = sqrt(trace(MMSE.A*MMSE.A')./P) %tinh he so cua bo MMSE
theo cong thuc (3.6)
for k=1:K
MRT.receivedpower = 1+(1/MRT.beta.^2)*norm(H(:,k).'*conj(H)).^2;
%nang luong tin hieu nhan duoc tai user k gom ca interference va nois theo cong thuc (3.17)
MRT.desiredpower = (1/MRT.beta.^2)*norm(H(:,k)).^4; % nang luong tin
58
MRT.rate_userk(k,r)= log2(1+MRT.desiredpower/(MRT.receivedpower- MRT.desiredpower)); %rate cua K user tai vong lap r tinh theo cong thuc (3.17)
ZF.receivedpower = 1+(1/ZF.beta.^2)*norm(H(:,k).'*conj(H)*ZF.G).^2;
%nang luong tin hieu nhan duoc tai user k gom ca interference va noise theo cong thuc (3.13)
ZF.desiredpower = (1/ZF.beta.^2)*norm(H(:,k).'*conj(H)*ZF.G(:,k)).^2;
% nang luong cua tin hieu mong muon nhan duoc tai user k theo cong thuc (3.13)
ZF.rate_userk(k,r)= log2(1+ZF.desiredpower/(ZF.receivedpower- ZF.desiredpower)); %rate cua K user tai vong lap r theo SNR thu p tin theo cong
thuc (3.13)
MMSE.receivedpower =
1+(1/MMSE.beta.^2)*norm(H(:,k).'*conj(H)*MMSE.G).^2; %nang luong tin hieu nhan duoc tai user k gom ca interference va noise theo cong thuc (3.9)
MMSE.desiredpower =
(1/MMSE.beta.^2)*norm(H(:,k).'*conj(H)*MMSE.G(:,k)).^2; %nang luong tin hieu mong muon nhan tai user k
MMSE.rate_userk(k,r) =
log2(1+MMSE.desiredpower/(MMSE.receivedpower-MMSE.desiredpower));
%rate tinh theo cong thuc (3.9)
end
end
MRT.rate_Kusers(p,:) =
(sum(MRT.rate_userk,2)./monteCarloRealizations).';%Tinh gia tri trung binh
cua rate cho K user theo monteCarloRealization vong lap
ZF.rate_Kusers(p,:) = (sum(ZF.rate_userk,2)./monteCarloRealizations).';%Tinh
gia tri trung binh cua rate cho K user theo monteCarloRealization doi voi SNR (p)
59
MMSE.rate_Kusers(p,:) =
(sum(MMSE.rate_userk,2)./monteCarloRealizations).'; %Tinh gia tri trung binh
cua rate cho K user theo monteCarloRealization doi voi SNR (p)
end MRT.sumrate = sum(MRT.rate_Kusers,2); ZF.sumrate = sum(ZF.rate_Kusers,2); MMSE.sumrate = sum(MMSE.rate_Kusers,2); figure(1); plot(PdBvar,MRT.sumrate,'y-s',PdBvar,ZF.sumrate,'g- o',PdBvar,MMSE.sumrate,'b-*'); grid on;
xlabel('Signal to Noise Ratio SNR [dB]'); ylabel('SumRate [bits/s/Hz]');
legend('MRT Precoder','ZF Precoder','MMSE Precoder','Location','northwest'); figure(2);
plot(PdBvar,MRT.rate_Kusers(:,1).','y-s',PdBvar,ZF.rate_Kusers(:,1).','g- o',PdBvar,MMSE.rate_Kusers(:,1).','b-*'); grid on;
xlabel('Singal to Noise Ratio SNR [dB]');
ylabel('The achievable rate of user 1 [bits/s/Hz]');
60
Code mô phỏng hiệu năng của hệ thống theo số lượng anten trạm gốc M
close all; % dong tat ca cac chuong trinh khac dang chay voi matlab
clear all; % xoa tat ca cac bien duoc matlab tao khi chay cac chuong trinh truoc
do
Mantennas=30:10:110; %So luong antenna Kusers=10; %So luong nguoi dung
PdBvar=10; %SNR ti so cong suat tin hieu tren nhieu, don vi dB, coi P_noise=1
thi P=SNR.
monteCarloRealizations = 10000; % monteCarloRealizations la so vong lap thong ke cua he thong
for m = 1:length(Mantennas) M = Mantennas(m); K = Kusers; P = 10^(PdBvar/10); Hfull = (randn(M,K,monteCarloRealizations)+1i*randn(M,K,monteCarloRealizations)) /sqrt(2);
% ma tran Hfull kich thuoc MxK duoc tao ra la kenh truyen giua M antenna tram goc
%va K nguoi dung. Hfull~CN(0,1).
s_real=(randn(K,1,monteCarloRealizations)+1i*randn(K,1,monteCarloRealizat ions))/sqrt(2); % vecto symbol input
n_real=(randn(K,1,monteCarloRealizations)+1i*randn(K,1,monteCarloRealizat ions))/sqrt(2); %nhieu Gauss ~CN(0,1) tai noi nhan.
for r = 1:monteCarloRealizations
r %khi go lenh r ma bo qua dau “;” thi gia tri r se hien thi tren man hinh H = Hfull(:,:,r); %lenh nay trich xuat ma tran kenh cua vong lap thu r trong
ma tran Hfull.
s = s_real(:,:,r); %vecto symbol input n = n_real(:,:,r); %vecto noise
61
MRT.beta = sqrt(trace(H.'*conj(H))./P); %tinh he so cua bo MRT theo cong thuc (3.14)
ZF.G = inv(H.'*conj(H)); %thanh phan cua ma tran ZF A ZF.A = conj(H)*ZF.G; % ma tran ZF Precoding
ZF.beta = sqrt(trace(ZF.A*ZF.A')./P); %tinh he so cua bo ZF theo cong thuc
(3.10)
MMSE.G = inv(H.'*conj(H)+K*eye(K)./P); %thanh phan cua ma tran MMSE
A
MMSE.A = conj(H)*MMSE.G; %ma tran MMSE Precoding
MMSE.beta = sqrt(trace(MMSE.A*MMSE.A')./P) %tinh he so cua bo MMSE
theo cong thuc (3.6)
for k=1:K
MRT.receivedpower = 1+(1/MRT.beta.^2)*norm(H(:,k).'*conj(H)).^2;
%nang luong tin hieu nhan duoc tai user k gom ca interference va nois theo cong thuc (3.17)
MRT.desiredpower = (1/MRT.beta.^2)*norm(H(:,k)).^4; % nang luong tin
hieu mong muon nhan duoc tai user k
MRT.rate_userk(k,r)= log2(1+MRT.desiredpower/(MRT.receivedpower- MRT.desiredpower)); %rate cua K user tai vong lap r tinh theo cong thuc (3.17) ZF.receivedpower = 1+(1/ZF.beta.^2)*norm(H(:,k).'*conj(H)*ZF.G).^2;
%nang luong tin hieu nhan duoc tai user k gom ca interference va noise theo cong thuc (3.13)
ZF.desiredpower = (1/ZF.beta.^2)*norm(H(:,k).'*conj(H)*ZF.G(:,k)).^2;
% nang luong cua tin hieu mong muon nhan duoc tai user k theo cong thuc (3.13)
ZF.rate_userk(k,r)= log2(1+ZF.desiredpower/(ZF.receivedpower- ZF.desiredpower)); %rate cua K user tai vong lap r theo SNR thu p tin theo cong
thuc (3.13)
MMSE.receivedpower =
1+(1/MMSE.beta.^2)*norm(H(:,k).'*conj(H)*MMSE.G).^2; %nang luong tin hieu nhan duoc tai user k gom ca interference va noise theo cong thuc (3.9)
MMSE.desiredpower =
(1/MMSE.beta.^2)*norm(H(:,k).'*conj(H)*MMSE.G(:,k)).^2; %nang luong tin hieu mong muon nhan tai user k
62
MMSE.rate_userk(k,r) =
log2(1+MMSE.desiredpower/(MMSE.receivedpower-MMSE.desiredpower));
%rate tinh theo cong thuc (3.9)
end
end
MRT.rate_Kusers(m,:) =
(sum(MRT.rate_userk,2)./monteCarloRealizations).';%Tinh gia tri trung binh
cua rate cho K user theo monteCarloRealization vong lap
ZF.rate_Kusers(m,:) =
(sum(ZF.rate_userk,2)./monteCarloRealizations).';%Tinh gia tri trung binh cua
rate cho K user theo monteCarloRealization doi voi SNR (p)
MMSE.rate_Kusers(m,:) =
(sum(MMSE.rate_userk,2)./monteCarloRealizations).'; %Tinh gia tri trung binh
cua rate cho K user theo monteCarloRealization doi voi SNR (p)
end MRT.sumrate = sum(MRT.rate_Kusers,2); ZF.sumrate = sum(ZF.rate_Kusers,2); MMSE.sumrate = sum(MMSE.rate_Kusers,2); figure(1); plot(Mantennas,MRT.sumrate,'y-s',Mantennas,ZF.sumrate,'r- o',Mantennas,MMSE.sumrate,'b-*'); grid on;
xlabel('So luong anten tai tram goc M'); ylabel('SumRate [bits/s/Hz]');
legend('MRT Precoder','ZF Precoder','MMSE Precoder','Location','northwest'); figure(2);
plot(Mantennas,MRT.rate_Kusers(:,1).','y-s',Mantennas,ZF.rate_Kusers(:,1).','r- o',Mantennas,MMSE.rate_Kusers(:,1).','b-*'); grid on;
xlabel('So luong anten tai tram goc M');
ylabel('The achievable rate of user 1 [bits/s/Hz]');
63