📄 waterfill_single.m
字号:
%Single User Waterfilling
%Authors: Screen Lee
%Date: 12/05/06
function [Ex] = waterfill_single(H, p);
%Returns optimal covariance matrix
%where H is effective channel matrix
%etc.
%Function Inputs
%H: double indexed channel
%p: power in linear units
%Function Outputs
%Ex: double indexed matrices containing the capacity achieving
% covariance matrices
%Other Variables
%M: # number of base station antennas in uplink channel
%N: # number of terminal antennas in uplink channel
[M,N] = size(H);
%Perform SVD of channel
s = svd(H'* H);
channels = length(s);
s = real(s);
%Eliminate zeroes
s = max(s, 1e-10);
noise_vector = 1./s;
% unsortedN = noise_vector;
%Put noise variances in increasing order
noise_vector = sort(noise_vector);
last = channels; %index of worst channel allocated non-zero power
loop = 1;
%Find channels allocated non-zero power
while (loop)
water = noise_vector(last); %water level
power = sum(max(water - noise_vector, 0));
if (power > p)
last = last - 1;
else
loop = 0;
end;
end;
%Calculate optimal water level
water = 1/last * (p + sum(noise_vector(1:last)));
% Ex = zeros(N,N,K);
Ex=zeros(N,N);
%Take svd of channel
[u,v,w] = svd(H'* H);
s = svd(H' * H);
s = real(s);
%eliminate zeroes
s = max(s, 1e-10);
noise_vector = 1./s;
Ex = u * diag(max((water- noise_vector),0)) * u';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -