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

📄 measurementgfactor.m

📁 基于OFDM的无线宽带系统仿真It contains mainly two parts, i.e. link-level simulator and system-level simulator.
💻 M
📖 第 1 页 / 共 2 页
字号:
    %
    %     curr_snr=st_measurement.sinr_avg(round(abs(st_testConfig.locBS(2)-st_testConfig.locMS(lp_nmob)))+1);

    %Compare
    % 10*log10(curr_snr)
    %against
    %10*log10(st_mobileStations(lp_nmob).sinrFeedBack(lp_nmob))

    % STORE THE FEEDBACK SINR
    % It may be used in the next frame or may not be used,
    % It will be used only if the next frame is the beginning of a new
    % scheduling boundary
    % CHECK IF THE AVERAGING IS SAME AS IS DONE FOR THE NEW MOBILE
    %         st_mobileStations(lp_nmob).sinrFeedBack(lp_nuSubChannels)=mean(mean(sinr(:,(cnt_lp_sub_chan-1)*st_baseStation.nuSubCarrPerSubChan+1:(cnt_lp_sub_chan)*st_baseStation.nuSubCarrPerSubChan  ),1));
    %         st_mobileStations(lp_nmob).sinrStore(st_testConfig.nFrmCnt,lp_nuSubChannels)=st_mobileStations(lp_nmob).sinrFeedBack(lp_nuSubChannels);
%     for lp_all_subChan=1:st_baseStation.nuSubChannels
        sinr_sub_chan= (mean(sinr));
        st_mobileStations(lp_nmob).sinrFeedBack=sinr_sub_chan;%mean(mean(sinr(:,(cnt_lp_sub_chan-1)*st_baseStation.nuSubCarrPerSubChan+1:(cnt_lp_sub_chan)*st_baseStation.nuSubCarrPerSubChan  ),1));
%         st_mobileStations(lp_nmob).sinrStore(mod(st_testConfig.nFrmCntSlot,st_testConfig.nuFrmPerSlot)+1)=sinr_sub_chan;%st_mobileStations(lp_nmob).sinrFeedBack(lp_nuSubChannels);
%     end


    % Storing the SINR and Distance for later analysis
    st_measurement.sinrCnt=st_measurement.sinrCnt+1;
    st_measurement.sinrAvgMeas(st_measurement.sinrCnt)=(st_mobileStations(lp_nmob).sinrFeedBack);
    st_measurement.sinrAvgMeasDist(st_measurement.sinrCnt)=round(abs(st_testConfig.locBS(2)-st_testConfig.locMS(lp_nmob)));
    st_mobileStations(lp_nmob).RemFileSz(mod(st_testConfig.nFrmCntSlot,st_testConfig.nuFrmPerSlot)+1)=-20;
    %     % LOOK UP THE SNR VS FER TABLE
    %     cnt_lp_sub_chan=0;
    %     total_bits_sent_by_mobile_in_this_frame=0;
    %     for lp_nuSubChannels=sub_chan_allocated%1:num_sub_carr_alloc %sub_carrs_allocated
    %         cnt_lp_sub_chan=cnt_lp_sub_chan+1;
    %
    %         curr_sinr = mean(mean(sinr(:,sub_carrs_allocated( (cnt_lp_sub_chan-1)*st_baseStation.nuSubCarrPerSubChan+1:(cnt_lp_sub_chan)*st_baseStation.nuSubCarrPerSubChan) )));
    %
    %
    %         % READ UP ERROR PROBABILITY from the appropriate table for the rate
    %         switch st_baseStation.mod(lp_nuSubChannels,1,1);
    %             case    0
    %                 colidx=12;%7;
    %
    %             case    1
    %                 switch st_baseStation.fec(lp_nuSubChannels,1,1);
    %                     case 1/4
    %                         colidx=2;
    %                     case 1/3
    %                         colidx=3;
    %                 end
    %             case    2
    %                 switch st_baseStation.fec(lp_nuSubChannels,1,1);
    %                     case    1/3
    %                         colidx=4;%3;
    %                     case    1/2
    %                         colidx=5;%4;
    %                         %case    2/3
    %                         %    colidx=5;
    %                 end
    %             case    4
    %                 switch st_baseStation.fec(lp_nuSubChannels,1,1);
    %                     case    1/3
    %                         colidx=6;
    %                     case    1/2
    %                         colidx=7;
    %                     case    2/3
    %                         colidx=8;
    %                 end
    %             case    6
    %                 switch st_baseStation.fec(lp_nuSubChannels,1,1);
    %                     case    1/3
    %                         colidx=9;
    %                     case    1/2
    %                         colidx=10;
    %                     case    2/3
    %                         colidx=11;
    %                 end
    %         end
    %
    %
    %         % FIND THE ROW INDEX FROM WHERE TO READ THE FER VALUE
    %         %         Idx1=1;
    %         %         Idx2=1;
    %         Idx=1;
    %         Idx1 = max(find(st_testConfig.FerLin<=curr_sinr));
    %         Idx2 = min(find(st_testConfig.FerLin>=curr_sinr));
    %         %         Idx=mean(Idx1,Idx2);
    %
    %         Fer=1;
    %         % 1 means the frame is in error
    %         % 0 means frame not in error
    %
    %         if Idx>0
    %             Fer1 = st_testConfig.FerdB(Idx1,colidx); %LOOK UP THE FER TABLE TO FIND THE FER
    %             Fer2 = st_testConfig.FerdB(Idx2,colidx);
    %             Fer = mean([Fer1 Fer2]);
    %         end
    %
    %         % TRY A DICE TO FIND WHETHER THIS FRAME IS IN ERROR
    %         % STORE THIS RESULT AS BELOW
    %         % STORE THE FRAME BEING IN ERROR OR NOT IN AN ARRAY FOR EACH POSITION
    %         % OF THE MOBILE
    %         randnum=rand;
    %         st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCntSlot,lp_nuSubChannels)=(randnum <= Fer);
    %         if colidx == 12 % if there is no modulation and coding
    %         else
    %             st_measurement.totalFramesinError=st_measurement.totalFramesinError+st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCntSlot,lp_nuSubChannels);
    %         end
    %
    %         %         st_measurement.totalFramesinError=st_measurement.totalFramesinError+st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCntSlot,lp_nuSubChannels);
    %         % CHECK IF THE REMAINING FILE SIZE IS POSITIVE THEN ONLY IT MAKES
    %         % SENSE TO CALCULATE THE FRAME (0.5MS) BEING IN ERROR OR NOT AND
    %         % THE ASSOCIATED SUCCESSFUL BITS SENT ETC....
    %
    %
    %         % update the number of bits to be sent in the next frame
    %         nuBitsInFrame = st_mobileStations(lp_nmob).modStore(st_testConfig.nFrmCntSlot,lp_nuSubChannels)*st_mobileStations(lp_nmob).fecStore(st_testConfig.nFrmCntSlot,lp_nuSubChannels)*st_baseStation.nuSubCarrPerSubChan*st_testConfig.nuOfdmSymbPerFrame;
    %         if ((st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCntSlot,lp_nuSubChannels))==1) % if the frame is in Error
    %             % Do not reduce the number of bits to be send
    %             %st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCntSlot+1)=st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCntSlot);
    %             %st_mobileStations(lp_nmob).RemFileSz(mod(st_testConfig.nFrmCntSlot,st_testConfig.nuFrmPerSlot)+1)=st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCntSlot);
    %         else
    %             % Reduce the number of bits to be sent
    %             %st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCnt)=st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCnt)-nuBitsInFrame;
    %             total_bits_sent_by_mobile_in_this_frame=total_bits_sent_by_mobile_in_this_frame+nuBitsInFrame;
    %         end
    %
    %         % ALSO LOOK UP THE THROUGHPUT CURVE
    %         % FIND THE THROUGHPUT AND STORE IT AT THE LOCATION
    %         %         st_mobileStations(lp_nmob).Thpt(st_testConfig.nFrmCnt,cnt_lp_sub_chan)=(1-Fer)*st_baseStation.nuSubCarrPerSubChan*num_sub_chan_alloc*st_testConfig.nuOfdmSymbPerFrame*(st_baseStation.mod(lp_nuSubChannels,1,1))*(st_baseStation.fec(lp_nuSubChannels,1,1));
    %         st_mobileStations(lp_nmob).Thpt(st_testConfig.nFrmCntSlot,cnt_lp_sub_chan)=(1-Fer)*nuBitsInFrame;
    %
    %         % COMPARE THE DIFFERENCE IN THE ABOVE TWO METHODS
    %         %[10*log10(st_mobileStations(lp_nmob).sinrFeedBack(lp_nmob))
    %         %10*log10(curr_snr) ; st_baseStation.mod(1,1,sub_chan_allocated) st_baseStation.fec(1,1,sub_chan_allocated); st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCnt,cnt_lp_sub_chan) randnum ;Fer 0]
    %     end
    %
    %     st_measurement.totalBitsSent=st_measurement.totalBitsSent+total_bits_sent_by_mobile_in_this_frame;
    %     st_mobileStations(lp_nmob).RemFileSz(mod(st_testConfig.nFrmCntSlot,st_testConfig.nuFrmPerSlot)+1)=st_mobileStations(lp_nmob).RemFileSz(st_testConfig.nFrmCntSlot)-total_bits_sent_by_mobile_in_this_frame;
    %     if st_baseStation.scheduler_Algo >=4
    %         st_mobileStations(lp_nmob).ThptAvgPast =  st_mobileStations(lp_nmob).ThptAvgPast*(1-1/st_baseStation.tcNuFrames) + total_bits_sent_by_mobile_in_this_frame/st_baseStation.tcNuFrames;
    %     end

    %%%[
    %%%10*log10(st_mobileStations(lp_nmob).sinrStore(st_testConfig.nFrmCntSlot,:)).'  st_mobileStations(lp_nmob).modStore(st_testConfig.nFrmCntSlot,sub_chan_allocated).' st_mobileStations(lp_nmob).fecStore(st_testConfig.nFrmCntSlot,sub_chan_allocated).' 10*log10(st_mobileStations(lp_nmob).sinrStore(mod(st_testConfig.nFrmCntSlot,st_testConfig.nuFrmPerSlot)+1,:).') st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCntSlot,:).']
    %figure(4)
    %subplot(211);plot(1:st_baseStation.nuSubChannels,10*log10(st_mobileStations(lp_nmob).sinrStore(st_testConfig.nFrmCntSlot,:)),'r-o',1:st_baseStation.nuSubChannels, 10*log10(st_mobileStations(lp_nmob).sinrStore(mod(st_testConfig.nFrmCntSlot,st_testConfig.nuFrmPerSlot)+1,:).'),'k-v',1:st_baseStation.nuSubChannels, st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCntSlot,:)*max(10*log10(st_mobileStations(lp_nmob).sinrStore(st_testConfig.nFrmCntSlot,:))),'g-d');subplot(212);plot(1:st_baseStation.nuSubChannels,st_mobileStations(lp_nmob).modStore(st_testConfig.nFrmCntSlot,:),'b-*',1:st_baseStation.nuSubChannels, st_mobileStations(lp_nmob).fecStore(st_testConfig.nFrmCntSlot,:),'k-s',1:st_baseStation.nuSubChannels, st_mobileStations(lp_nmob).FrminError(st_testConfig.nFrmCntSlot,:),'g-d')
end

⌨️ 快捷键说明

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