📄 generate_bulk_par.m
字号:
% STEPS 9a-9d [1, Sec. 5.5.4]
% Note that MsDirection below effectively overrides the one given in
% the input struct LINKPAR. Note also that MS array orientation is not
% actually needed anywhere.
MsDirection = 360*(rand(NumLinks,1)-0.5); % step 9a: generate MS DoT = Street Orientation
%MsArrayDir = 360*(rand(NumLinks,1)-0.5); % step 9b: generate MS Array orientation
alpha = 0.9; % percentage of links experiencing urban canyon effect
p_DoT = 0.5;
offset = 180;
% Select the links that experience urban canyon
beta = rand(1,NumLinks); % step 9c
uc_links = find(beta<=alpha);
nuc_links = find(beta>alpha); % these links do not experience the canyon
% Generate the AoAs for the urban canyon links
delta_aoa = MsDirection;
offset_links = uc_links(find(rand(length(uc_links),1)>p_DoT));
delta_aoa(offset_links) = MsDirection(offset_links)+offset;
delta_aoa = repmat(delta_aoa,1,N);
% Generate the AoAs for non-canyon links
P_nuc_links = P(nuc_links,:);
sigma_aoa_nuc_links = 104.12*(1-exp(-0.2175*abs(10*log10(P_nuc_links))));
delta_aoa(nuc_links,:) = randn(length(nuc_links),N).*sigma_aoa_nuc_links; % a (NumLinks x N) matrix of path AoAs
delta_aoa = reshape(delta_aoa.',NumLinks*N,1);
delta_aoa = repmat(delta_aoa,1,M).'; % a (M x (NumLinks*N)) matrix
else % Urban Canyon option not used
% step 9
sigma_aoa = 104.12*(1-exp(-0.2175*abs(10*log10(P))));
delta_aoa = randn(NumLinks,N).*sigma_aoa; % a (NumLinks x N) matrix of path AoAs
delta_aoa = reshape(delta_aoa.',NumLinks*N,1);
delta_aoa = repmat(delta_aoa,1,M).'; % a (M x (NumLinks*N)) matrix
end
% step 10: determine the offset AoAs at the MS
aoa_35deg = [1.5679 4.9447 8.7224 13.0045 17.9492 23.7899 30.9538 40.1824 53.1816 75.4274]; % [1, Table 5.2]
delta_nm_aoa = [aoa_35deg; -aoa_35deg];
delta_nm_aoa = delta_nm_aoa(:); % these are the same for all links and paths
delta_nm_aoa = repmat(delta_nm_aoa,1,N*NumLinks); % a (M x N*NumLinks) matrix
% step 11: pair AoA subpaths randomly with AoD subpaths (within a path)
[dummy h] = sort(rand(M,N*NumLinks),1); % create N*NumLinks random permutations of integers [1:M]
inds = h+repmat([1:M:M*N*NumLinks],M,1)-1;
delta_nm_aoa_paired = delta_nm_aoa(inds); % random permutation of columns, a (M x N*NumLinks) matrix
% step 12: determine angles depending on array orientation
ThetaBs = repmat(ThetaBs,N,1); ThetaBs=ThetaBs(:).';
ThetaBs = repmat(ThetaBs,M,1); % a (M x N*NumLinks) matrix
theta_nm_aod = ThetaBs+delta_aod+delta_nm_aod;
ThetaMs = repmat(ThetaMs,N,1); ThetaMs=ThetaMs(:).';
ThetaMs = repmat(ThetaMs,M,1); % a (M x N*NumLinks) matrix
theta_nm_aoa = ThetaMs + delta_aoa+delta_nm_aoa_paired;
else % use fixed AoD/AoAs (without random pairing of subpaths)
delta_aod=fixedAods(scmpar); % the same for each link
delta_aod= repmat(delta_aod,1,NumLinks); % a (M x (NumLinks*N)) matrix
ThetaBs = repmat(ThetaBs,N,1); ThetaBs=ThetaBs(:).';
ThetaBs = repmat(ThetaBs,M,1); % a (M x N*NumLinks) matrix
theta_nm_aod = ThetaBs+delta_aod;
delta_aoa=fixedAoas(scmpar); % the same for each link
delta_aoa= repmat(delta_aoa,1,NumLinks); % a (M x (NumLinks*N)) matrix
ThetaMs = repmat(ThetaMs,N,1); ThetaMs=ThetaMs(:).';
ThetaMs = repmat(ThetaMs,M,1); % a (M x N*NumLinks) matrix
theta_nm_aoa = ThetaMs+delta_aoa;
end
% Values of theta_nm_aoa and theta_nm_aod may be outside (-180,180).
% This is corrected in the following.
theta_nm_aoa=prin_value(theta_nm_aoa);
theta_nm_aod=prin_value(theta_nm_aod);
% put AoDs, AoAs, and power gains into a 3D-array with dims [NumLinks N M]
theta_nm_aod=reshape(theta_nm_aod,M,N,NumLinks);
theta_nm_aod=permute(theta_nm_aod,[3 2 1]);
theta_nm_aoa=reshape(theta_nm_aoa,M,N,NumLinks);
theta_nm_aoa=permute(theta_nm_aoa,[3 2 1]);
% step 13: Path loss and shadowing
% employ the user-defined path loss model
path_losses=feval(scmpar.PathLossModel,scmpar,linkpar);
path_losses=10.^(-path_losses(:)/10); % a (NumLinks x 1) vector
% optional steps for polarized arrays and output generation
switch (lower(ScmOptions))
case ('los')
switch lower(scmpar.Scenario)
case {'suburban_macro'}
LOS_probability=max([zeros(size(MsBsDistance)); (40/50)* (5000-MsBsDistance)./5000]); %
prob=rand(size(LOS_probability));
LOS_probability=LOS_probability.*(prob<=LOS_probability);
% calculate K factors of the links -- K factor > 0 only if LOS_probability>0
K_factors=10.^((15.4-5*log10(MsBsDistance))/10);
K_factors=K_factors.*(LOS_probability~=0); % in linear scale
K_factors=K_factors(:);
case {'urban_macro'}
LOS_probability=max([zeros(size(MsBsDistance)); (15/30)*(500-MsBsDistance)./500]); %
prob=rand(size(LOS_probability));
LOS_probability=LOS_probability.*(prob<=LOS_probability);
% calculate K factors of the links -- K factor > 0 only if LOS_probability>0
K_factors=10.^((15.4-5*log10(MsBsDistance))/10);
K_factors=K_factors.*(LOS_probability~=0); % in linear scale
K_factors=K_factors(:);
end
% set the LOS phase randomly
Phi_LOS=360*(rand(NumLinks,1)-0.5);
phi= 360*rand(NumLinks,N,M); % random phases for all users
% output
bulk_parameters=struct( 'delays',taus_rounded,...
'path_powers',P,... % before: 'subpath_powers',Psub,...
'aods',theta_nm_aod,...
'aoas',theta_nm_aoa,...
'subpath_phases',phi,...
'K_factors',K_factors,... % in linear scale
'Phi_LOS',Phi_LOS,... % phases for LOS paths, in degrees
'path_losses',path_losses,... % in linear scale
'shadow_fading',sigma_sf); % in linear scale
case ('polarized') % [1, Sec. 5.5.1]
% Step 13 - dummy step
% Step 14 - dummy step
% Step 15 - generates random phases
phi = 360*rand(NumLinks,4,N,M); % random phases for all users: [NumLinks pol path subpath]
% Step 16 - dummy step
% Step 17 - generate XPD ratios
A = 0.34*10*log10(P)+7.2; % in dB
B = 5.5; % in dB
xpd_in_db = zeros(NumLinks,2,N);
xpd_in_db(:,1,:)=A+B*randn(size(A)); % V-to-H coupling
xpd_in_db(:,2,:)=A+B*randn(size(A)); % H-to-V coupling
xpd=10.^(xpd_in_db/10); % size()=[NumLinks pol N], xpd(:,1,:) is V-to-H coupling
% output
bulk_parameters=struct( 'delays',taus_rounded,...
'path_powers',P,... % before: 'subpath_powers',Psub,...
'aods',theta_nm_aod,... % in degrees
'aoas',theta_nm_aoa,... % in degrees
'subpath_phases',phi,... % in degrees
'xpd',xpd,... % in linear scale
'path_losses',path_losses,... % in linear scale
'shadow_fading',sigma_sf); % in linear scale
case {'none','urban_canyon'}
phi= 360*rand(NumLinks,N,M); % random phases for all users
% output
bulk_parameters=struct( 'delays',taus_rounded,...
'path_powers',P,... % before: 'subpath_powers',Psub,...
'aods',theta_nm_aod,... % in degrees
'aoas',theta_nm_aoa,... % in degrees
'subpath_phases',phi,... % in degrees
'path_losses',path_losses,... % in linear scale
'shadow_fading',sigma_sf); % in linear scale
end
if strcmpi(IntraClusterDsUsed,'yes')
bulk_parameters.NumSubPathsPerMidpath=NumSubPathsPerMidpath;
bulk_parameters.MidPathOrder= MidPathOrder;
bulk_parameters.MidPathPowers= MidPathPowers;
bulk_parameters.MidPathDelays=MidPathDelays;
bulk_parameters.path_powers_all=Pall;
end
% end of function 'macro'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A function to generate urban micro cell parameters
function bulk_parameters=micro(scmpar,linkpar,antpar)
% extract the number of users from the first field of linkpar struct
MsBsDistance =linkpar.MsBsDistance;
NumLinks =length(MsBsDistance);
% extract certain parameters from the input structs
ScmOptions =scmpar.ScmOptions;
N =scmpar.NumPaths;
M =scmpar.NumSubPathsPerPath;
DelaySamplingInterval =scmpar.DelaySamplingInterval;
FixedPdpUsed = scmpar.FixedPdpUsed;
IntraClusterDsUsed = scmpar.IntraClusterDsUsed;
% check that M=20
if (M ~= 20)
M=20;
warning('MATLAB:NumSubPathsChanged','NumSubPaths is not 20! Using NumSubPaths=20 instead.')
end
% if bandwidth extension is used
if strcmpi(IntraClusterDsUsed,'yes')
NumSubPathsPerMidpath=[6,6,4,4];
MidPathOrder= [1,2,3,4,19,20,5,6,7,8,17,18,9,10,15,16,11,12,13,14];
MidPathDelays=[0 5.8e-009 1.35e-008 2.76e-008]; % relative to path/cluster delay
MidPathPowers=[6/20 6/20 4/20 4/20]; % relative to path power
end
% make sure that user-specific parameters are row vectors
MsBsDistance=linkpar.MsBsDistance(:).';
ThetaBs =linkpar.ThetaBs(:).';
ThetaMs =linkpar.ThetaMs(:).';
% general environment parameters for urban micro [1, Table 5.1]
max_ds =1.2e-6; % maximum excess delay in seconds
max_aod =40; % maximum AoD angle in degrees
sigma_rnd =3; % per-path shadowing std in dB, needed in step 6
% step 3: determine DS, AS and SF for all users
% This step takes into account channel scenario automatically
% path loss is computed in step 13
sigma_sf=step3(scmpar,linkpar); % a (NumLinks x 1) matrix
sigma_sf=sigma_sf(:);
% step 4 & step 5: generate delays in a (NumLinks x N) matrix
% The unit of taus is seconds
if strcmpi(FixedPdpUsed,'no')
taus=sort(max_ds*rand(NumLinks,N),2); % sorted path delays for all users
taus=taus-repmat(taus(:,1),1,N ); % normalize min. delay to zero
if strcmpi(IntraClusterDsUsed,'yes') % add the fixed midpath delays
taus_all=repmat(taus,[1 1 length(MidPathDelays)]);
taus_all=permute(taus_all,[1 3 2]);
taus_all=reshape(taus_all,NumLinks,length(MidPathDelays)*N);
taus_all=taus_all+repmat(MidPathDelays,NumLinks,N);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -