📄 measurementgfactor.m
字号:
function [cnt_meas,st_measurement,st_mobileStations] = measurementGfactor(cnt_meas,st_channelGrid,st_measurement,st_baseStation,st_mobileStations,st_testConfig)
% This function will measure the signal to interference plus noise ratio at
% each OFDM symbol at each sub carrier for each mobile at each location,
% for as many frames as being simulated.
% Then will find the Frame in error or not and will record it
% It will also store the allocated modulation and FEC rate
% It will also store the Feedback SINR to be used in the next round of
% frame transmission
% update path gain matrix
% g=pathgain(st_testConfig.locMS,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);
g = threeSectorpathGain(st_testConfig.locMS,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);
g_lin = 10.^(g/10);
[signalStrengths, connectedBs]= max(g_lin,[],2);
% del_Sigma=[];
% g_sec=[];
% g_main=pathgain(st_testConfig.locMS,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(:,:,2),st_channelGrid.mapvecShadow(:,:,2));
%
% for kk=1:st_testConfig.nuCellPerCluster
% del_Sigma(:,:,kk)=multi_shadow(st_testConfig.locMS,st_testConfig.locBS,st_testConfig.fib,st_testConfig.rombvec,st_testConfig.attConst,st_testConfig.alpha, st_testConfig.sigma_y, st_testConfig.raa, st_testConfig.lobeVector, st_channelGrid.lognmapShadow(:,:,kk),st_channelGrid.mapvecShadow(:,:,kk),g_main);
% g_sec=horzcat(g_sec,del_Sigma(:,kk,kk));
% end
%
% g=g_main+g_sec;
% g_lin = 10.^(g/10);
% sub_chan_alloc_chart(1:st_baseStation.nuSubChannels)=st_baseStation.allocation(1:st_baseStation.nuSubChannels,1,1);
for lp_nmob=1:st_testConfig.nuMob
% % % find the subchannels allocated to the current mobile handle index
% % sub_chan_allocated = find(sub_chan_alloc_chart==lp_nmob); %
% % % num_sub_chan_alloc=length(sub_chan_allocated); % this will be used to find the frame in error or not for each
% % %time frequency resource unit
%
% % For Block allocation
% % This assumes that for the 2 ms frame , one user gets the same set of
% % sub carriers continuously. i.e. there is no Time Frequency
% % scheduling. Only Frequency domain scheduling.
%
% % THIS HAS TO CHANGE LATER ON TO PER 0.5 MS, SO THAT TIME FREQUENCY
% % SCHEDULING CAN BE VERIFIED. THIS CAN BE DONE VERY EASILY BY JUST
% % CHANGING THE DEFINITION OF 'st_testConfig.nuOfdmSymbPerFrame' IN THE
% % TEST CONFIG FILE , AS OF NOW THERE IS NO 2 MS, ALL ARE 0.5 MS .
%
% % WHEN THAT CHANGE WILL BE DONE, THEN THE SCHEDULER HAS TO BE UPDATED
% % SO THAT A MATRIX IS MADE WHICH IS HAVING TIME FREQUENCY DIMENSION,
% % WHERE MOBILE INDEXS WILL BE STORED WHICH WILL IDENTIFY THE TIME
% % FREQUENCY RESOURCE TO BE ALLOCATED TO THE MOBILE. THIS INFORMATION
% % HAS TO BE UPDATED EVERY 2/5/10/20 MS, WHERE AS THIS MATRIX SHOULD BE
% % READ EVERY 0.5 MS FOR SUB CARRIER ALLOCATION
%
% % This loop find the sub carrier indexes allocated to the current user.
% % A user may have more than one sub channel allocated to him/her
% % This may be used in the calculations of SINR
% % sub_carrs_allocated=[];
% % for lp_num_sub_chan_alloc=sub_chan_allocated
% % sub_carrs_allocated = [sub_carrs_allocated (lp_num_sub_chan_alloc-1)*st_baseStation.nuSubCarrPerSubChan+1:lp_num_sub_chan_alloc*st_baseStation.nuSubCarrPerSubChan]; %
% % end
% % num_sub_carr_alloc=length(sub_carrs_allocated);
%
% % For each OFDM symbol in the frame
% % cnt_meas=cnt_meas+1;
for lp_nuOFDMSymbs = 1:st_testConfig.nuOfdmSymbPerSubFrame
%
% % for each link to a Base station in the first tier
% for lp_nBs = 1:st_testConfig.nuBs
%
% % switch st_testConfig.pdp
% % case 'exponential'
% % pdp_db = 10*log10(exp(-st_channelGrid.tau/st_channelGrid.tau_rms(lp_nmob,lp_nBs)));
% % otherwise
% % end
% %create channel object
% % chObj = rayleighchan(st_testConfig.tSymb,abs(st_testConfig.veloMS(lp_nmob))*5/18/3e8*st_testConfig.cf ,st_channelGrid.tau,pdp_db);
% % Bring back to the state the channel was in
% % reset(chObj,st_mobileStations(lp_nmob).randstate(lp_nBs,1,1));
%
% % To update the channel object upto the time instant needed
% % tmp_var=[ones(st_testConfig.feedBackDelayIntervalNuOfdms+lp_nuOFDMSymbs,1) ];
%
% tmp_var=filter(st_mobileStations(lp_nmob).ch_obj(lp_nBs,1,1),1);
%
% ctf(lp_nBs,1:st_testConfig.nuSubCarr)=fft(st_mobileStations(lp_nmob).ch_obj(lp_nBs,1,1).PathGains,st_testConfig.nuSubCarr);
%
% end
% % Measure SINR
% %desiredPart = g_lin(lp_nmob,2)*abs(ctf(2,1:st_testConfig.nuSubCarr)).^2;
% % desiredPart = g_lin(lp_nmob,2)*abs(ctf(2,1:sub_carrs_allocated)).^2;
% % %---------------
% % measure from the maximum of all base stations.
desiredPart = g_lin(lp_nmob,connectedBs(lp_nmob));%*abs(ctf(connectedBs(lp_nmob),1:st_testConfig.nuSubCarr)).^2;
% indices of interfering base stations
intfBsIdxvector = st_testConfig.listBs(st_testConfig.listBs~=connectedBs(lp_nmob));
% interferece(1:num_sub_carr_alloc)=0;
interferece=0;
for lp_bsIdx = [intfBsIdxvector]
%interferece(1:num_sub_carr_alloc)=interferece(1:num_sub_carr_alloc)+g_lin(lp_nmob,lp_bsIdx)*abs(ctf(lp_bsIdx,sub_carrs_allocated)).^2;
interferece=interferece+g_lin(lp_nmob,lp_bsIdx);%*abs(ctf(lp_bsIdx, 1:st_testConfig.nuSubCarr)).^2;
end
% check the noise power calculation in this line sinr(lp_nuOFDMSymbs,1:st_testConfig.nuSubCarr)=desiredPart./(interferece+st_testConfig.noisePowerPerSubc/st_testConfig.PowerPerSubCperSublink);%sinr_tmp;
% sinr(lp_nuOFDMSymbs)=desiredPart./(interferece+st_testConfig.noisePowerPerSubCarrSet/st_testConfig.maxPowBsSubCarrSet);%sinr_tmp;
sinr(lp_nuOFDMSymbs)=desiredPart./(interferece+st_testConfig.noisePower/st_testConfig.maxPowBS);%sinr_tmp;
% sinr(lp_nuOFDMSymbs)=desiredPart./(interferece+st_testConfig.noisePower/st_testConfig.maxPowBsRevCalc);
% sinr(lp_nuOFDMSymbs)=desiredPart./(interferece+st_testConfig.noisePowerPerSubc/st_testConfig.maxPowBsSubCarr);
end
% Storing the average SINR at a user distance fromt the base station
% fac=st_measurement.cnt(round(abs(st_testConfig.locBS(2)-st_testConfig.locMS(lp_nmob)))+1);
% fac=fac+1;
% if num_sub_carr_alloc>0
% if fac~=1
% st_measurement.sinr_avg(round(abs(st_testConfig.locBS(2)-st_testConfig.locMS(lp_nmob)))+1)=mean(mean(sinr(sub_carrs_allocated)));
% else
% st_measurement.sinr_avg(round(abs(st_testConfig.locBS(2)-st_testConfig.locMS(lp_nmob)))+1)=1/2*(mean(mean(sinr(sub_carrs_allocated)))/fac+(1-1/fac)*st_measurement.sinr_avg(round(abs(st_testConfig.locBS(2)-st_testConfig.locMS(lp_nmob)))+1));
% end
% end
% st_measurement.cnt(round(abs(st_testConfig.locBS(2)-st_testConfig.locMS(lp_nmob)))+1)=fac;
% % st_mobileStations(lp_nmob).loc(st_testConfig.nFrmCntSlot)=st_testConfig.locMS(lp_nmob);
% st_mobileStations(lp_nmob).locMS(st_testConfig.nFrmCntSlot)=st_testConfig.locMS(lp_nmob);
%
%
% % CHECK THE RATE ALLOCATION AS PER LA SCHEME
% % STORE THE RATE PROMISED
%
% % st_mobileStations(lp_nmob).modStore(st_testConfig.nFrmCntSlot,1:num_sub_chan_alloc)=st_baseStation.mod(sub_chan_allocated,1,1);%.*st_baseStation.fecRate(lp_nmob,sub_carrs_allocated,1,1);
% % st_mobileStations(lp_nmob).fecStore(st_testConfig.nFrmCntSlot,1:num_sub_chan_alloc)=st_baseStation.fec(sub_chan_allocated,1,1);%.*st_baseStation.fecRate(lp_nmob,sub_carrs_allocated,1,1);
%
% st_mobileStations(lp_nmob).modStore(st_testConfig.nFrmCntSlot,sub_chan_allocated)=st_baseStation.mod(sub_chan_allocated,1,1);%.*st_baseStation.fecRate(lp_nmob,sub_carrs_allocated,1,1);
% st_mobileStations(lp_nmob).fecStore(st_testConfig.nFrmCntSlot,sub_chan_allocated)=st_baseStation.fec(sub_chan_allocated,1,1);%.*st_baseStation.fecRate(lp_nmob,sub_carrs_allocated,1,1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -