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

📄 ofdma_sfn_cellular_la_dl_simulator.m

📁 基于OFDM的无线宽带系统仿真It contains mainly two parts, i.e. link-level simulator and system-level simulator.
💻 M
📖 第 1 页 / 共 2 页
字号:
                % and its relationship with respect to the sub frame duration
                % and the power control loop update rate
                for subn_idx = 1:st_baseStation.nuSubChannels
                    %save yytmp subn_idx st_baseStation st_mobileStations
                    %keyboard
                    new_SINR_dB(subn_idx) = int8(round(10*log10(st_mobileStations(st_baseStation.allocation(subn_idx)).sinrFeedBack(subn_idx))));
                    %st_baseStation.poweradjust;
                    %new_SINR_dB = int8(round(10*log10(new_SINR)));
                    old_SINR_dB(subn_idx) = user_sinr(st_baseStation.allocation(subn_idx),mod(lp_nFrames-1 - st_initConfig.F_PA,st_initConfig.saveUserInfo_factor)+1,subn_idx);
                end
                P_inc = find(and(new_SINR_dB<old_SINR_dB,st_baseStation.poweradjust'~=0)==1);
                P_dec = find(and(new_SINR_dB>old_SINR_dB,st_baseStation.poweradjust'~=0)==1);
                st_baseStation.poweradjust(P_dec) = st_baseStation.poweradjust(P_dec) * (1 - 1/5);
                P_av = st_baseStation.nuSubChannels - sum(st_baseStation.poweradjust);
                P_need = sum(st_baseStation.poweradjust(P_inc)) * 1/5; 
                if P_need <= P_av,
                    st_baseStation.poweradjust(P_inc) = st_baseStation.poweradjust(P_inc) * (1 + 1/5); 
                else 
                    rat_fac = P_av/P_need; st_baseStation.poweradjust(P_inc) = st_baseStation.poweradjust(P_inc) * (1 + 1/5 * rat_fac); 
                end
            end
            %-------------------------------
            %-------------------------------
            % Do the power allocation. and put flags between the resource
            % allocation and the power allocation based on the frame period

            %-------------------------------
            %-------------------------------


            %lp_nFrames
            %if mod(st_initConfig.nFrmCnt-1,st_initConfig.FrameToSubTimeFrameRatio)==0
            %st_initConfig.saveUserInfo_factor = 100; % save user information per 100 subframes
            %save_UserInforCnt = mod(lp_nFrames-1,st_initConfig.saveUserInfo_factor) + 1;
            %save yytmp;
            for lp_nmob=1:st_initConfig.nuMob
                user_velocity(lp_nmob,save_UserInforCnt) = uint8(round(abs(st_initConfig.veloMS(lp_nmob))));
                user_distance(lp_nmob,save_UserInforCnt) = uint16(round(abs(st_initConfig.locMS(lp_nmob) - st_initConfig.locBS(st_initConfig.desiredBsIdx))));
                % this sinr is when no power adjustment is done
                user_sinr(lp_nmob,save_UserInforCnt,:) = int8(round(10*log10(st_mobileStations(lp_nmob).sinrFeedBack)));
                user_sinr_noFeedBackErr(lp_nmob,save_UserInforCnt,:) = int8(round(10*log10(st_mobileStations(lp_nmob).sinrFeedBackNoChErr)));
                user_mobID(lp_nmob,save_UserInforCnt) = uint16(st_mobileStations(lp_nmob).MobNumber(st_initConfig.nFrmCntSlot));
                user_ActiveCnt(lp_nmob,save_UserInforCnt) = uint16(st_mobileStations(lp_nmob).MobActiveCnt);
                user_fair(lp_nmob,save_UserInforCnt) = st_mobileStations(lp_nmob).fair;
            end
            %save_UserInfor_times = ceil(lp_nFrames/st_initConfig.saveUserInfo_factor); % how many times has been saved
            if save_UserInforCnt == st_initConfig.saveUserInfo_factor
                subdirname = 'user_gain_info_and_distance';
                if ~exist(subdirname,'dir'),mkdir(subdirname);end;
                save([subdirname,'/','saveIndex',num2str(save_UserInfor_times)],'user_velocity','user_distance','user_sinr','user_sinr_noFeedBackErr','user_mobID','user_ActiveCnt','user_fair');
            end

            % store the snr feedback and the current SNR
            % this is in the base station part
            for lp_nuSubChannels=1:st_baseStation.nuSubChannels
                st_measurement.snrFeedBackNoChErr(lp_nuSubChannels,save_UserInforCnt)=int8(round(10*log10(st_mobileStations(st_baseStation.allocation(lp_nuSubChannels,1,1)).sinrFeedBackNoChErr(lp_nuSubChannels))));
                % store the snr feedback and the current SNR with Error
                st_measurement.snrFeedBack(lp_nuSubChannels,save_UserInforCnt)=int8(round(10*log10(st_mobileStations(st_baseStation.allocation(lp_nuSubChannels,1,1)).sinrFeedBack(lp_nuSubChannels))));
            end
            %------------------------------
            % Store the allocation information for saving
            % and later analysis
            %-----------------------------

            %-----------------------------
            % fill all channel values for all ofdm symbols
            %-----------------------------
            % This can be done in the measurement unit, one mobile, one link at a
            % time and the history then cleared to have minimum memory requirements



            %CALL FUNCTION TO STORE THE CHANNEL COEFFS TO BE USED FOR LINK
            %ADAPTATIO. UPDATE THE CHANNEL OBJECT BELONGING TO THE MOBILE AT THE
            %SAME TIME. ALSO UPDATE REQUIRED PARAMETERS

            %-----------------------------
            % CALL THE MEASUREMENT FUNCTION
            %-----------------------------

            %%measure the SINR for all sub carriers, i.e measure the sinr for each
            %%sub carrier set (sub channel), therefore it considers path loss plus shadowing plus
            %%frequency selective fading
            [cnt_meas,st_measurement,st_mobileStations] = measurement2(cnt_meas,st_channelGrid,st_measurement,st_baseStation,st_mobileStations,st_initConfig);

            %save_UserInfor_times = ceil(lp_nFrames/st_initConfig.saveUserInfo_factor); % how many times has been saved




            for lp_nmob=1:st_initConfig.nuMob
                st_measurement.ThptAvgPast(lp_nmob,save_UserInforCnt)=st_mobileStations(lp_nmob).ThptAvgPast;
                st_measurement.Thpt(lp_nmob,save_UserInforCnt)=st_mobileStations(lp_nmob).Thpt;
                st_measurement.remFileSzStore(lp_nmob,save_UserInforCnt)=int32(round(st_mobileStations(lp_nmob).RemFileSz(mod(st_initConfig.nFrmCntSlot,st_initConfig.nuFrmPerSlot)+1)));
            end
            for lp_nuSubChannels=1:st_baseStation.nuSubChannels
                % the value of the modulation used, use unit8
                st_measurement.modStore(lp_nuSubChannels,save_UserInforCnt)=uint8(st_baseStation.mod(lp_nuSubChannels,1,1));
                st_measurement.poweradjust(lp_nuSubChannels,save_UserInforCnt) = st_baseStation.poweradjust((lp_nuSubChannels),1,1);
                % the value of the fec used, use double
                st_measurement.fecStore(lp_nuSubChannels,save_UserInforCnt)=int8(round(10*st_baseStation.fec(lp_nuSubChannels,1,1)));
                % the value of the mobile idx, which is the identification of a
                % particular mobile and not the handle
                st_measurement.mobIdxStore(lp_nuSubChannels,save_UserInforCnt)=uint16(st_baseStation.mobId(lp_nuSubChannels,1,1));
                % store the distance between the mobile and the base station
                st_measurement.distanceStore(lp_nuSubChannels,save_UserInforCnt)=uint16(ceil((st_baseStation.ueDistance(lp_nuSubChannels,1,1))));
                % store the snr the current SNR
                st_measurement.snrAfterAMC(lp_nuSubChannels,save_UserInforCnt)=int8(round(10*log10(st_mobileStations(st_baseStation.allocation(lp_nuSubChannels,1,1)).sinrFeedBack(lp_nuSubChannels))));
                % store the snr the current SNR
                st_measurement.snrAfterAMCNoChErr(lp_nuSubChannels,save_UserInforCnt)=int8(round(10*log10(st_mobileStations(st_baseStation.allocation(lp_nuSubChannels,1,1)).sinrFeedBackNoChErr(lp_nuSubChannels))));


                %remaining file size. a -ve value indicates completed
                %transmission

            end
    end

    st_measurement.instThpt(save_UserInforCnt)=(st_measurement.totalBitsSent)/(st_initConfig.nFrmCnt*st_initConfig.subFramePeriod);
    if save_UserInforCnt == st_initConfig.saveUserInfo_factor
        subdirname = 'measurement';
        if ~exist(subdirname,'dir'),mkdir(subdirname);end;
        save([subdirname,'/','dataVals',num2str(save_UserInfor_times)],'st_measurement');
    end
    if mod(lp_nFrames,50)==0
        ['Frm No.=' num2str(st_initConfig.nFrmCnt) ' Nu Usrs=' num2str(MobileIdCnt) ' out=' num2str(st_measurement.outageCnt)  ' T=' num2str((st_initConfig.nFrmCnt)*st_initConfig.subFramePeriod) 's' ]

        ['bps/Hz=' num2str(st_measurement.instThpt(save_UserInforCnt)/st_initConfig.bw) '  Mbps=' num2str(st_measurement.instThpt(save_UserInforCnt)/(1024*1024)) ' KB=' num2str(round(st_measurement.totalBitsSent)/(8*1024))]
    end
    % INCREASE THE TIMER BY THE TIME EQUAL TO THE SUB FRAME DURATION
    st_initConfig.currTimeinSec=st_initConfig.currTimeinSec+st_initConfig.subFramePeriod;
end % end of loop for number for frames

⌨️ 快捷键说明

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