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

📄 update_mobile_structres_before_frame_g_fac_no_fsf.m

📁 基于OFDM的无线宽带系统仿真It contains mainly two parts, i.e. link-level simulator and system-level simulator.
💻 M
📖 第 1 页 / 共 2 页
字号:
% % location and velocities of the old mobiles need to be restored to the
% % state of the last call
% % old_mobile_handle_indexes(1:length(old_mobile_handles))=old_mobile_handles;
%
switch st_testConfig.handOffFlg
    case 'nohandoff'
    locMStemporary=st_testConfig.locMS;
    veloMStemporary=st_testConfig.veloMS;

    new_mobiles_flag = 0; % New mobile connection flag
    % 0 means that the connection are not ok
    % 1 means connections are ok
    all_mobile_index=1:st_testConfig.nuMob;
    new_mobile_handles_ref=new_mobile_handles;% store indexes of new mobiles

    while new_mobiles_flag == 0 % While all new mobiles are not ok

        new_mobiles_flag=1;% set the flag to true

        %find gains between mobiles and bases
        g = threeSectorpathGain(locMStemporary,st_testConfig.locBS,st_testConfig.fib,st_testConfig.rombvec,st_testConfig.attConst,st_testConfig.alpha, st_testConfig.sigma, st_testConfig.raa, st_testConfig.lobeVector, st_channelGrid.lognmapShadow,st_channelGrid.mapvecShadow, st_testConfig.sps, st_testConfig.nuCluster, st_testConfig.ncell_per_cluster,st_testConfig.dmin);
        % select only those for the new mobile locations
        g_new_mob=zeros(size(g));
        g_new_mob(1:st_testConfig.nuMob,st_testConfig.desiredBsIdx)=1;
        g_new_mob(new_mobile_handles_ref,1:st_testConfig.nuBs)=g(new_mobile_handles_ref,:);

        %Store the indexes of the NEW mobiles which were in proper
        %locations earlier i.e. connected to the desired BS 2
        %         if st_testConfig.nFrmCnt > 1
        %         new_mobile_handles_ref_old=new_mobile_handles_ref;
        %
        %         end
        %
        % check if they can be connected to the base station 2
        [val,mob_idx]=max(g_new_mob,[],2);
        new_mobile_handles_ref=all_mobile_index(mob_idx~=st_testConfig.desiredBsIdx); % store the 'NEW mobile' handler
        % indexes
        % which are
        % not
        % connected to
        % desired BS

        if size(new_mobile_handles_ref,2)~=0% if at least one NEW mobile is not connected to the BS 2 then
            new_mobiles_flag=0;       % change flag to false status
            locMStemporary(new_mobile_handles_ref)=nan;% make those indexes nan so that mobmove can assign them new values
            veloMStemporary(new_mobile_handles_ref)=nan;
            % find new locations for the mobiles which are out of reach
            % from the desired BS 
            [locMStemporary,veloMStemporary]=mobmoveScale(locMStemporary,veloMStemporary,st_testConfig.aMean,st_testConfig.vMean,st_testConfig.dT,st_testConfig.rombvec,st_testConfig.centerBsLoc);
        end

    end
    % assign the old mobiles their original location and velocities
    % and the new mobiles generated must get their valid positions and
    % velocities
    st_testConfig.locMS(new_mobile_handles)=locMStemporary(new_mobile_handles);
    st_testConfig.veloMS(new_mobile_handles)=veloMStemporary(new_mobile_handles);

end


% Plot location of mobiles which starts transmitting
figure(1);
hold on;
plot(st_testConfig.locMS(new_mobile_handles),'m.');
pause(0.0011)

st_testConfig.veloMS(abs(st_testConfig.veloMS)>st_testConfig.max_veloms)=st_testConfig.max_veloms*.75*exp(-j*randn);


%
% %Distance of mobiles from cells
%
% distance_matrix=abs(repmat((st_testConfig.locMS),1,length(st_testConfig.locBS))-  repmat(st_testConfig.locBS,length(st_testConfig.locMS),1))/1e3;
%
%
% %use this distance to calculate the rms delay spread as per the Vinko Erceg
% %Model.
% % tau_rms=(st_channelGrid.T1).*(distance_matrix.^(st_channelGrid.epsilon)).*(repmat((10.^((st_channelGrid.logn(:,:,2))/10)),1,length(st_testConfig.locBS)));
%
% tau_rms=(st_channelGrid.T1).*(distance_matrix.^(st_channelGrid.epsilon)).*(repmat((10.^((st_channelGrid.logn)/10)),1,length(st_testConfig.locBS)));
%
% % Limit the maximum value of rms delay spread to reduce simulation time and
% % to take away the impact of interference insufficient guard interval
% max_tau_rms=max(max(tau_rms));
% max_tau = 6*max_tau_rms;
% if max_tau>st_testConfig.tSymb
%     max_tau=st_testConfig.tSymb;
% end
%
% L_max = ceil(max_tau/st_testConfig.tSample);
% tau=0:st_testConfig.tSample:st_testConfig.tSample*L_max-st_testConfig.tSample;
%
%
% for lp_nmob=1:st_testConfig.nuMob
%
%     matching_indexes=(new_mobile_handles==lp_nmob); % Find whether the current mobile handle number
%     % has a new mobile
%     % connection
%
%     flag_new_mobile=sum(matching_indexes);          % create the logic variable for it
%     if flag_new_mobile == 1                         % If the current mobile handle is a new mobile then
%         % create channel object
%         % for it
%         % and initialize it to
%         % a random state
%
%         % store the location of the mobile unit, since it will be used in later calculations to draw different figures
%         st_mobileStations(lp_nmob).locMS(st_testConfig.nFrmCntSlot)=st_testConfig.locMS(lp_nmob);
%         for lp_nBs=1:st_testConfig.nuBs;%CellPerCluster
%             switch st_testConfig.pdp
%                 case 'exponential'
%                     pdp_db = 10*log10(exp(-tau/tau_rms(lp_nmob,lp_nBs)));
%                 otherwise
%             end
%             for lp_nTxAntenna=1:st_testConfig.nuAntennaBS
%                 for lp_nRxAntenna=1:st_testConfig.nuAntennaMS
%                     %                 st_mobileStations(lp_nmob).ch_obj(lp_nBs,lp_nTxAntenna,lp_nRxAntenna) = rayleighchan(st_testConfig.tSymb,abs(st_testConfig.veloMS(lp_nmob))*5/18/3e8*st_testConfig.cf ,tau,pdp_db);
%                     st_mobileStations(lp_nmob).ch_obj(lp_nBs,lp_nTxAntenna,lp_nRxAntenna) = rayleighchan(st_testConfig.tSymb,abs(st_testConfig.veloMS(lp_nmob))*5/18/3e8*st_testConfig.cf ,tau,pdp_db);
%                     %                     st_mobileStations(lp_nmob).randstate(lp_nBs,lp_nTxAntenna,lp_nRxAntenna) = round(rand*1e5);
%                     %                     reset(st_mobileStations(lp_nmob).ch_obj(lp_nBs,lp_nTxAntenna,lp_nRxAntenna),st_mobileStations(lp_nmob).randstate(lp_nBs,lp_nTxAntenna,lp_nRxAntenna));
%                     reset(st_mobileStations(lp_nmob).ch_obj(lp_nBs,lp_nTxAntenna,lp_nRxAntenna),round(rand*1e5));
%                     %                 st_mobileStations(lp_nmob).ch_obj(lp_nBs,lp_nTxAntenna,lp_nRxAntenna)=chObj;
%                     %                 st_mobileStations(lp_nmob).cir(lp_nBs,lp_nTxAntenna,lp_nRxAntenna,1:length(chObj.PathGains))=chObj.PathGains;
%                     st_mobileStations(lp_nmob).ch_obj(lp_nBs,lp_nTxAntenna,lp_nRxAntenna).ResetBeforeFiltering = 0;
%                 end
%             end
%         end
%     else                                            % If the current mobile handle is not for a new mobile
%         % then do not create a
%         % new channel object
%     end
% end
% st_channelGrid.distance_matrix=distance_matrix;
% % st_channelGrid.logn=logn;
% st_channelGrid.tau_rms=tau_rms;
% st_channelGrid.L_max=L_max;
% st_channelGrid.tau=tau;

⌨️ 快捷键说明

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