%This code could implement the Hybrid precoding.
%there are 3 styles methods: MRT, ZF, hybrid precoding.
%the power normalization based per user.
%and power allocation by water-filliing methods.
close all;
clear all;
%%Simulation parameters
randn('state',sum(100*clock));%产生整函数对应的随机种子
Nantennas = [128]; % the number of antennas
Ntx = [64]; % the number of RF chains.
K = 64; %the number of Users.
%Number of realizations in the Monte Carlo simulations
nbrOfMonteCarloRealizations = 100; %100;
%the parameters of channel.
corr_H = false;
channelVariances = ones(1,K);
%User weights for (unweighted) sum rate computation
weights = ones(K,1);
%Range of SNR values
PdB = -5:5:30; %dB scale,SNR
P = 10.^(PdB/10); %Linear scale,power with noise normalization
%%
%%Pre-allocation of matrices
%Matrices for saving sum rates with different beamforming stategies
sumRateMRT = zeros(length(P),nbrOfMonteCarloRealizations,length(Ntx));%MRT-rate-matrix
sumRateZFBF = zeros(length(P),nbrOfMonteCarloRealizations,length(Ntx));%ZFBF-rate-matrix
sumRateRenHybrid = zeros(length(P),nbrOfMonteCarloRealizations,length(Ntx));%Hybrid-rate-matrix
%Go through the different number of transmit antennas
for n = 1:length(Nantennas)
for rr= 1:length(Ntx)
NTx = Ntx(rr);
%Extract the current number of antennas
N = Nantennas(n);
%Pre-generation of Rayleigh fading channel realizations (unit variance)
Hall = (randn(K,N,nbrOfMonteCarloRealizations)+1i*randn(K,N,nbrOfMonteCarloRealizations))/sqrt(2);
v = (randn(K,N,nbrOfMonteCarloRealizations)+1i*randn(K,N,nbrOfMonteCarloRealizations))/sqrt(2);%channel error matrix
%LK = LargeScaleFading (K);
LK = eye(K);
%Sita = AntennaCorrlation (N,1);
Sita = eye(N);
%Go through all channel realizations
for m = 1:nbrOfMonteCarloRealizations
%Output the progress
disp(['Progress: N = ' num2str(NTx) ', ' num2str(m) ' out of ' num2str(nbrOfMonteCarloRealizations) ' realizations.']);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Generate the channel
if corr_H == true %If the channel correlation exists;
tao = 0;
%H = sqrt(LK)* Hall(:,:,m)*sqrt(Sita);%ideal channel model
Hv = sqrt(LK)* (sqrt(1-tao^2)*Hall(:,:,m)+tao*v(:,:,m))*sqrt(Sita);%non-ideal channel model
end
if corr_H == false
Hv = repmat(sqrt(channelVariances)',[1 N]) .* Hall(:,:,m);% for Rayleigh fading channel
end
%Compute normalized beamforming vectors for MRT-ZFBF-Hybrid
wMRT = functionMRT(Hv);
wZFBF = functionZFBF(Hv);
wRenHybrid = functionRenHybrid(Hv, NTx);
%[norm(wZFBF), norm(wRenHybrid)]
for pind = 1:length(P)
%Calculate power allocation with MRT (using Theorem 3.5 in [7])
rhos = diag(abs(Hv*wMRT).^2)';
powerAllocationMRT = functionHeuristicPowerAllocation(rhos,P(pind),weights);
%Calculate sum rate with MRT
W = kron(sqrt(powerAllocationMRT),ones(N,1)).*wMRT;
channelGains = abs(Hv*W).^2;
signalGains = diag(channelGains);
interferenceGains = sum(channelGains,2)-signalGains;
rates = log2(1+signalGains./(interferenceGains+1));
sumRateMRT(pind,m,rr) = weights'*rates;
%Calculate power allocation with ZFBF (using Theorem 3.5 in [7])
rhos = diag(abs(Hv*wZFBF).^2)';
powerAllocationwZFBF = functionHeuristicPowerAllocation(rhos,P(pind),weights);
W = kron(sqrt(powerAllocationwZFBF),ones(N,1)).*wZFBF;
channelGains = abs(Hv*W).^2;
signalGains = diag(channelGains);
interferenceGains = sum(channelGains,2)-signalGains;
rates = log2(1+signalGains./(interferenceGains+1));
sumRateZFBF(pind,m,rr) = weights'*rates;
%Calculate power allocation with wRenHybrid (using Theorem 3.5 in [7])
rhos = diag(abs(Hv*wRenHybrid).^2)';
powerAllocationwRenHybrid = functionHeuristicPowerAllocation(rhos,P(pind),weights);
W = kron(sqrt(powerAllocationwRenHybrid),ones(N,1)).*wRenHybrid;
channelGains = abs(Hv*W).^2;
signalGains = diag(channelGains);
interferenceGains = sum(channelGains,2)-signalGains;
rates = log2(1+signalGains./(interferenceGains+1));
sumRateRenHybrid(pind,m,rr) = weights'*rates;
end
end
end
end
%Plot simulation results
for n = 1:length(Ntx)
figure; hold on; box on;
plot(PdB,mean(sumRateRenHybrid(:,:,n),2),'k-','LineWidth',1);
plot(PdB,mean(sumRateZFBF(:,:,n),2),'b--','LineWidth',1);
plot(PdB,mean(sumRateMRT(:,:,n),2),'r*-','LineWidth',1);
legend('sumRateRenHybrid','ZFBF','MRT','Location','NorthWest');
title(['N = ' num2str(Ntx(n)) ' antennas']);
xlabel('Average SNR [dB]')
ylabel('Average Sum Rate [bit/channel use]');
end
Two-Stage.zip.zip_beamforming in MIMO_beamforming mimo_loveMATLA
版权申诉
35 浏览量
2022-07-15
12:27:42
上传
评论
收藏 7KB ZIP 举报
钱亚锋
- 粉丝: 90
- 资源: 1万+
最新资源
- 10Eclipse项目源码.jpg
- 大屏可视化数据课程项目
- Maven 快速入门指南:安装和配置方法详解
- STM32物信息通过MQTT协议上传云平台
- STM32物信息通过MQTT协议上传云平台
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6260.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6259.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6258.0)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本122.0.6257.0)
- Screenshot_2024_0614_022736.png
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈