📄 update_mobile_structres_before_frame2.m
字号:
function [st_channelGrid,st_initConfig,st_mobileStations,MobileIdCnt,st_baseStation,st_measurement]= update_mobile_structres_before_frame2(st_initConfig,st_channelGrid,st_mobileStations,MobileIdCnt,st_baseStation,st_measurement)%__________________________________________________________________________% Type: : Function Header% Function name : ofdma_sfn_Cellular_la_dl_simulator% input : st_channelGrid,st_initConfig,st_mobileStations,st_baseStations% output : st_channelGrid,st_initConfig,st_mobileStations,st_baseStations% :% calling functions : input_config% called functions :% Function Description : % Update mobile structure.% its acceleraion% its position, therefore% its pathloss% settings of channel object% its history to zero. No need to store history now% its rms delay spread as per the distance.% its doppler as per the new velocity% ALSO UPDATE REQUIRED PARAMETERS%__________________________________________________________________________% Update new velocity and location% if st_initConfig.nFrmCnt > 1% figure(1);% hold on;% plot(st_initConfig.locMS,'g.');% end% Check each mobile, if the remaining file size to be trasmitted is less% than zero. If so, then initiate a new mobile in that handlenew_mobile_handles=[];finished_locs=nan(1,st_initConfig.nuMob);%[];bad_mobiles_loc=nan(1,st_initConfig.nuMob);%[];old_mobile_handles=[];%ch_matrixPointer = ones(1,st_initConfig.chnums);for lp_nmob =1:st_initConfig.nuMob % IDENTIFY MOBILE WHICH ARE NOT ABLE TO GET THROUGH BUT ARE SIMPLY BLOCKING % THE NETWORK RESOURCES. % TAKE THEM AWAY FROM THE NETWORK, i.e. DO NOT SERVE THEM ANY MORE AND MARK % THEM WITH A YELLOW STAR if st_initConfig.nFrmCnt > st_initConfig.MAX_OFDM_SYMBOL_WAIT... && mean(st_mobileStations(lp_nmob).sinrFeedBackNoChErr) < 10^((st_initConfig.SINR_Threshold)/10)... && (st_mobileStations(lp_nmob).RemFileSz(st_initConfig.nFrmCntSlot)... == st_mobileStations(lp_nmob).RemFileSz(mod((st_initConfig.nFrmCntSlot-st_initConfig.MAX_OFDM_SYMBOL_WAIT-1),st_initConfig.nuFrmPerSlot)+1))... && (st_mobileStations(lp_nmob).MobNumber(st_initConfig.nFrmCntSlot)... == st_mobileStations(lp_nmob).MobNumber(mod((st_initConfig.nFrmCntSlot-st_initConfig.MAX_OFDM_SYMBOL_WAIT),st_initConfig.nuFrmPerSlot)+1)), bad_mobiles_loc=st_initConfig.locMS(lp_nmob); st_mobileStations(lp_nmob).RemFileSz(st_initConfig.nFrmCntSlot) = -9999; st_measurement.outageCnt=st_measurement.outageCnt+1; end if st_mobileStations(lp_nmob).RemFileSz(st_initConfig.nFrmCntSlot)<=0 new_mobile_handles = [new_mobile_handles lp_nmob];% Store the mobile handle number % set state to finished only when it's not bad, and not during the % first frame transmission. if st_mobileStations(lp_nmob).RemFileSz(st_initConfig.nFrmCntSlot)~=-9999 && st_initConfig.nFrmCnt > 1, finished_locs(lp_nmob)=st_initConfig.locMS(lp_nmob); end % to be used in channel creation MobileIdCnt=MobileIdCnt+1; st_mobileStations(lp_nmob).MobNumber(st_initConfig.nFrmCntSlot) = MobileIdCnt; st_mobileStations(lp_nmob).RemFileSz(st_initConfig.nFrmCntSlot)=st_initConfig.MaxFileSz;%*(1 + randint(1,1,st_initConfig.tast_file_size_max_ratio*100)/100); st_mobileStations(lp_nmob).MobActiveCnt = 1; % This value might need to be changed. st_initConfig.locMS(lp_nmob)=nan; st_initConfig.veloMS(lp_nmob)=nan; st_mobileStations(lp_nmob).targetUEthpt = st_initConfig.targetUEthpt; else % Store the handles for the mobile handlers who will continue with % the same old mobiles old_mobile_handles=[old_mobile_handles lp_nmob]; st_mobileStations(lp_nmob).MobNumber(st_initConfig.nFrmCntSlot) = st_mobileStations(lp_nmob).MobNumber(mod(st_initConfig.nFrmCntSlot-2,st_initConfig.nuFrmPerSlot)+1); st_mobileStations(lp_nmob).MobActiveCnt = st_mobileStations(lp_nmob).MobActiveCnt + 1; endendst_baseStation.new_mobile_handles=new_mobile_handles; % show results every time% as of now this function will create a random drop of users this will be% changed very soon where users who have finished trasmitting will quit the% system while new users will join: This latter part has been accomplised[st_initConfig.locMS,st_initConfig.veloMS]=... mobmoveScale(st_initConfig.locMS,st_initConfig.veloMS,st_initConfig.aMean,st_initConfig.vMean,... st_initConfig.dT,st_initConfig.rombvec,st_initConfig.centerBsLoc,st_initConfig.locBS(st_initConfig.desiredBsIdx),st_initConfig.dmin);% % Store the location and velocities of the old mobiles. This is needed,% % since the mobmove function will be called several times and location of% % the old mobiles would get updated, which is not desired. Therefore the% % location and velocities of the old mobiles need to be restored to the% % state of the last call%switch st_initConfig.handOffFlg case 'nohandoff' % only continue if there are new mobiles. reduce complexity locMStemporary=st_initConfig.locMS; veloMStemporary=st_initConfig.veloMS; all_mobile_index=1:st_initConfig.nuMob; new_mobiles_flag = isempty(st_baseStation.new_mobile_handles); % New mobile connection flag while new_mobiles_flag == 0 % While all new mobiles are not ok g = threeSectorpathGain(locMStemporary,st_initConfig.locBS,st_initConfig.fib,st_initConfig.rombvec,st_initConfig.attConst,st_initConfig.alpha, st_initConfig.sigma, st_initConfig.raa, st_initConfig.lobeVector, st_channelGrid.lognmapShadow,st_channelGrid.mapvecShadow, st_initConfig.sps, st_initConfig.nuCluster, st_initConfig.ncell_per_cluster,st_initConfig.dmin); [val,mob_idx]=max(g,[],2); new_mobile_handles_ref=all_mobile_index(mob_idx~=st_initConfig.desiredBsIdx); % store the 'NEW mobile' handler if ~isempty(new_mobile_handles_ref)% if at least one NEW mobile is not connected to the BS 2 then locMStemporary(new_mobile_handles_ref)=nan;% make those indexes nan so that mobmove can assign them new values veloMStemporary(new_mobile_handles_ref)=nan; [locMStemporary,veloMStemporary]=... mobmoveScale(locMStemporary,veloMStemporary,st_initConfig.aMean,st_initConfig.vMean,... st_initConfig.dT,st_initConfig.rombvec,st_initConfig.centerBsLoc,st_initConfig.locBS(st_initConfig.desiredBsIdx),st_initConfig.dmin); else new_mobiles_flag = 1; end end st_initConfig.locMS(new_mobile_handles)=locMStemporary(new_mobile_handles); st_initConfig.veloMS(new_mobile_handles)=veloMStemporary(new_mobile_handles);endst_initConfig.veloMS(abs(st_initConfig.veloMS)>st_initConfig.max_veloms)=(1 + 2*st_initConfig.vFactor*randint(1,1,10000)/10000)*st_initConfig.min_veloms*exp(-j*randn);st_initConfig.veloMS(abs(st_initConfig.veloMS)<st_initConfig.min_veloms)=(1 + 2*st_initConfig.vFactor*randint(1,1,10000)/10000)*st_initConfig.min_veloms*exp(-j*randn);distance_matrix=abs(repmat((st_initConfig.locMS),1,length(st_initConfig.locBS))- repmat(st_initConfig.locBS,length(st_initConfig.locMS),1))/1e3;for lp_nmob=st_baseStation.new_mobile_handles for lp_nBs=1:st_initConfig.nuBs;%CellPerCluster for lp_nTxAntenna=1:st_initConfig.nuAntennaBS for lp_nRxAntenna=1:st_initConfig.nuAntennaMS st_mobileStations(lp_nmob).ch_idx(lp_nBs,lp_nTxAntenna,lp_nRxAntenna) = randint(1,1,[st_initConfig.chnums_min st_initConfig.chnums_max]); tmp = randint; if tmp == 0, tmp = -1; end st_mobileStations(lp_nmob).ch_step(lp_nBs,lp_nTxAntenna,lp_nRxAntenna) = tmp; end end endendst_channelGrid.distance_matrix=distance_matrix;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -