⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 generate_bulk_par.m

📁 3gpp信道模型代码
💻 M
📖 第 1 页 / 共 4 页
字号:
else    % use fixed delays from a table [2]
    if strcmpi(IntraClusterDsUsed,'yes')
        taus_all=[0  5.8000e-009  1.3500e-008  2.7600e-008  2.0470e-007  2.1050e-007  2.1820e-007  2.3230e-007  2.8400e-007  2.8980e-007  ...
            2.9750e-007  3.1160e-007  6.6230e-007  6.6810e-007  6.7580e-007  6.8990e-007  8.0660e-007  8.1240e-007  8.2010e-007  8.3420e-007 ...
            9.2270e-007  9.2850e-007  9.3620e-007  9.5030e-007];
        taus=[0  2.0470e-007  2.8400e-007  6.6230e-007  8.0660e-007  9.2270e-007];
        taus_all=repmat(taus_all,NumLinks,1);
        taus=repmat(taus,NumLinks,1);
    else    % give only path/cluster delays
        taus=[0  2.0470e-007  2.8400e-007  6.6230e-007  8.0660e-007  9.2270e-007];
        taus=repmat(taus,NumLinks,1);
    end
end


% Rounding to delay grid
if strcmpi(IntraClusterDsUsed,'no')
    if (DelaySamplingInterval>0)
        taus_rounded=DelaySamplingInterval*floor( taus/DelaySamplingInterval + 0.5);
    else
        taus_rounded=taus;
    end
else
    if (DelaySamplingInterval>0)
        taus_rounded=DelaySamplingInterval*floor( taus_all/DelaySamplingInterval + 0.5);
    else
        taus_rounded=taus_all;
    end
end



% step 6: determine random average powers in a (NumLinks x N) matrix
if strcmpi(FixedPdpUsed,'no')
    z=randn(NumLinks,N)*sigma_rnd;       % per-path shadowing
    Pprime=10.^( -(taus/1e-6 + z/10) );
    P=Pprime./repmat(sum(Pprime,2),1,N);    % power normalization
    %Psub=repmat(P,[1 1 M])/M;       % a (NumLinks x N x M) array of subpath powers for all users
    if strcmpi(IntraClusterDsUsed,'yes')    % the fixed midpath powers
        Pall=repmat(P,[1 1 length(MidPathPowers)]);
        Pall=permute(Pall,[1 3 2]);
        Pall=reshape(Pall,NumLinks,length(MidPathPowers)*N);
        Pall=Pall.*repmat(MidPathPowers,NumLinks,N);
    end
else
    if strcmpi(IntraClusterDsUsed,'yes')
        Pall=[3.0084e-001  3.0084e-001  2.0056e-001  2.0056e-001  1.6082e-001  1.6082e-001  1.0721e-001  1.0721e-001  2.2477e-001  2.2477e-001 ...
             1.4985e-001  1.4985e-001  1.1185e-001  1.1185e-001  7.4564e-002  7.4564e-002  7.5327e-002  7.5327e-002  5.0218e-002  5.0218e-002 ...
            4.3182e-002  4.3182e-002  2.8788e-002  2.8788e-002];

        % normalization of path and midpath powers
        Pall=Pall/sum(Pall);
        Pall=repmat(Pall,NumLinks,1); % replicate to all links
        % path/cluster powers (needed for AoAs etc.)
        Pprime=[1.0028e+000  5.3607e-001  7.4923e-001  3.7282e-001  2.5109e-001  1.4394e-001];
        P=Pprime/sum(Pprime);   % normalization of path powers
        P=repmat(P,NumLinks,1); % replicate to all links
    else
        % path/cluster powers (needed for AoAs etc.)
        Pprime=[1.0028e+000  5.3607e-001  7.4923e-001  3.7282e-001  2.5109e-001  1.4394e-001];
        P=Pprime/sum(Pprime);   % normalization of path powers
        P=repmat(P,NumLinks,1); % replicate to all links
    end
end


if strcmpi(scmpar.FixedAnglesUsed,'no')
    % step 7: determine AoDs
    delta_aod=2*max_aod*(rand(NumLinks,N)-0.5);
    delta_aod=reshape(delta_aod.',NumLinks*N,1);
    delta_aod=repmat(delta_aod,1,M).';      % a (M x (NumLinks*N)) matrix



    % step 8: associate the path delays with AoDs (a dummy step)



    % step 9: determine the powers, phases and offset AoDs at the BS
    aod_5deg=[0.2236 0.7064 1.2461 1.8578 2.5642 3.3986 4.4220 5.7403 7.5974 10.7753]; % [1, Table 5.2]
    delta_nm_aod = [aod_5deg; -aod_5deg];
    delta_nm_aod=delta_nm_aod(:);   % this (M x 1) vector is the same for all users and paths
    delta_nm_aod=repmat(delta_nm_aod,1,N*NumLinks);  % a (NumLinks x N) matrix



    % step 10: determine the AoAs
    % If urban_canyon option is selected steps 10a-10d replace step 10
    if (strcmp(ScmOptions,'urban_canyon')==1)

        % STEPS 10a-10d  [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 10a: generate MS DoT = Street Orientation
        %MsArrayDir  = 360*(rand(NumLinks,1)-0.5);     % step 10b: 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 10c
        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.265*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 10
        sigma_aoa = 104.12*(1-exp(-0.265*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 11: 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 users and paths
    delta_nm_aoa    =repmat(delta_nm_aoa,1,N*NumLinks); % a (M x N*NumLinks) matrix


    % step 12: pair AoA subpaths randomly with AoD subpaths (within a path)
    [dummy h]           = sort(rand(M,N*NumLinks));       % 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 13: 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 % fixed AoD/AoAs are used, no 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]);   



% 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 
switch (lower(ScmOptions))   % [1, Sec. 5.5.1]
    
    case ('los')
        LOS_probability=max([zeros(size(MsBsDistance)); (300-MsBsDistance)./300]);
        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.^((13-0.03*MsBsDistance)/10); % [1, Sec. 5.5.3]
        K_factors=K_factors.*(LOS_probability~=0);  % in linear scale
        K_factors=K_factors(:);
        % 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')
        % 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=8;       % in dB
        B=8;       % in dB
        xpd_in_db=zeros(NumLinks,2,N);

        xpd_in_db(:,1,:)=A+B*randn(NumLinks,N);    % V-to-H coupling 
        xpd_in_db(:,2,:)=A+B*randn(NumLinks,N);    % 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,...
                                'aoas',theta_nm_aoa,...
                                'subpath_phases',phi,...
                                'path_losses',path_losses,...   % in dB 
                                '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 'micro'



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -