% --- Generate a clustered channel model for mmWave channels based on "Spatially sparse precoding in millimeter wave MIMO systems"
% --- [H, GainAlpha, Ar, At] = GenChannel (Nt, Nr, Ncls, Nray, sigGain, sigAngle, DirTX, DirRX)
% Input:
% Nt, number of transmit antennas, 1 x 1 for ULA, 1 x 2 for UPA
% Nr, number of receive antennas, 1 x 1 for ULA, 1 x 2 for UPA
% Ncls, number of clusters
% Nray, number of rays per cluster
% d, normalized antenna spacing
% sigGain, Ncls x 1, standard deviation of the gain of rays from each cluster, norm(sigGain, 2)^2 = Nt*Nr/Nray, normalized such that E[|H|^2] = Nt*Nr;
% sigAngle, 4 x 1, angular spread of departure azimuth, departure elevation, arrival azimuth, and arrival elevation
% DirTX, 2 x 2, TX directional antenna parameters [phi_min, phi_max phi: azimuth angle, theta: elevation angle
% theta_min, theta_max]
% DirRX, 2 x 2, RX directional antenna parameters [phi_min, phi_max
% theta_min, theta_max]
% Output: H, Nr x Nt, composite channel
% GainAlpha, Ncls*Nray , complex gains of each ray from each cluster
% Ar, Nr x (Ncls*Nray), aggregate receive array response vector
% At, Nt x (Ncls*Nray), aggregate transmit array response vector
% example: Nt = 64, Nr =16, Ncls = 8, Nray = 10
% sigGain = sqrt(Nt*Nr/(Ncls*Nray))*ones(Ncls, 1);
% sigAngle = 7.5*pi/180*ones(4, 1);
% DirTX = [-60, 60]*pi/180; DirRX = [-pi, pi];
% [H, GainAlpha, Ar, At] = GenChannel(Nt, Nr, Ncls, Nray, d, sigGain, sigAngle, DirTX, DirRX)
% [H, GainAlpha, Ar, At] = GenChannel(Nt, Nr, Ncls, Nray);
function [H, GainAlpha, At, Ar] = GenChannel(Nt, Nr, Ncls, Nray, DirTX, DirRX, d, sigGain, sigAngle)
% ============== Default Parameters setting ==========================
% ====================================================================
if (nargin <= 6) % set default
d = 0.5; % normalized antenna spacing
sigGain = sqrt(prod(Nt)*prod(Nr)/(Ncls*Nray)); % normalized such that E[|H|^2] = Nt*Nr
sigAngle = 7.5/180*pi*ones(4, 1);
end
% ====================================================================
% ====================================================================
Np = Ncls*Nray; % total paths
GainAlpha = zeros(Np, 1);% complex gains of paths
j = sqrt(-1);
% uniformly distributed mean angles
meanAngle(:, 1) = (2*rand(Ncls, 1)-1)*(DirTX(1, 2)-DirTX(1, 1))/2 + (DirTX(1, 2)+DirTX(1, 1))/2;% mean departure azimuth of each cluster
meanAngle(:, 2) = (2*rand(Ncls, 1)-1)*(DirTX(2, 2)-DirTX(2, 1))/2 + (DirTX(2, 2)+DirTX(2, 1))/2;% mean departure elevation of each cluster
meanAngle(:, 3) = (2*rand(Ncls, 1)-1)*(DirRX(1, 2)-DirRX(1, 1))/2 + (DirRX(1, 2)+DirRX(1, 1))/2;% mean arrival azimuth of each cluster
meanAngle(:, 4) = (2*rand(Ncls, 1)-1)*(DirRX(2, 2)-DirRX(2, 1))/2 + (DirRX(2, 2)+DirRX(2, 1))/2;% mean arrival elevation of each cluster
Ar = zeros(prod(Nr), Np);
At = zeros(prod(Nt), Np);
iN = 1;
while(iN <= Np)
icls = ceil(iN/Nray);% ith cluster
sig = sigGain;
GainAlpha(iN) = sig * (randn(1) + j*randn(1))/sqrt(2);
% sig = normrnd(0, sqrt(sigGain/Ncls));
% GainAlpha(iN) = sigGain * sig;
meanDepartAzi= meanAngle(icls, 1);
meanDepartElev = meanAngle(icls, 2);
meanArrivalAzi = meanAngle(icls, 3);
meanArrivalElev = meanAngle(icls, 4);
phi_t(iN) = genLaplacian( meanDepartAzi, sigAngle(1));
theta_t(iN) = genLaplacian( meanDepartElev, sigAngle(2));
phi_r(iN) = genLaplacian( meanArrivalAzi, sigAngle(3));
theta_r(iN) = genLaplacian( meanArrivalElev, sigAngle(4));
Wt = Nt(1);% TX array width, array dimension: Ht x Wt
Ht = Nt(2);% TX array height
Wr = Nr(1);% RX array width
Hr = Nr(2);% RX array height
DirGain(iN) = (phi_t(iN) > DirTX(1,1)) * ( phi_t(iN) < DirTX(1,2)) * (theta_t(iN) > DirTX(2,1)) * (theta_t(iN) < DirTX(2,2))* ...
(phi_r(iN) > DirRX(1,1)) * (phi_r(iN) < DirRX(1,2)) * (theta_r(iN) > DirRX(2,1)) * (theta_r(iN) < DirRX (2,2));
for it = 1 : Wt*Ht
iH = floor((it-1)/Wt);
iW = it - iH*Wt - 1;
At(it, iN) = 1/sqrt(Wt*Ht) * exp(j*2*pi*d*( iW*sin(phi_t(iN))*sin(theta_t(iN)) + iH*cos(theta_t(iN)) ));
end
for ir = 1 : Wr*Hr
iH = floor((ir-1)/Wr);
iW = ir - iH*Wr - 1;
Ar (ir, iN) = 1/sqrt(Wr*Hr) * exp(j*2*pi*d*( iW*sin(phi_r(iN))*sin(theta_r(iN)) + iH*cos(theta_r(iN)) ));
end
iN = iN + 1;
end
H = Ar * diag(GainAlpha)* diag(DirGain)* At'; %sigGain *
%%%%%%%%%% Generate a Laplacian variable with parameter {mu, sig}
% mean = mu, std deviation = sig
% Reference: wikipedia: http://en.wikipedia.org/wiki/Laplace_distribution
function X = genLaplacian(mu, sig)
b = sig/sqrt(2);
u = rand - 1/2;
X = mu - b*sign(u).*log(1-2*abs(u))/log(exp(1));
评论0