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

📄 dynamicsimu.m

📁 TD-SCDMA移动通信系统的系统级仿真平台
💻 M
字号:
% dynamicSimu.m; 动态仿真的主流程
% 首先要进行初始化,在初始化中包括业务的设置、话务量的设置等功能
%
%
%
CSserviceErl(1) = 5;        % 每平方公里的话务量
CSserviceErl(2) = 2;

CSserviceHoldtime(1) = 60;  % 实时业务的呼叫保持时间
CSserviceHoldtime(2) = 60;

totalArea = (xmax-xmin)*(ymax-ymin)/1000000;

serviceType = length(CSserviceErl);
totalCSserviceErl = CSserviceErl*totalArea;
lambda = totalCSserviceErl./CSserviceHoldtime;

%totalUser = zeros(totalCSserviceErl);       % 按业务类型进行累计
userIndex = 0;                              % 所有激活的用户个数,包括各类业务的总和,在这里的目的是为了显示

simuDuration = 20;
% 以秒为单位生成激活用户,形成仿真大循环

bar1 = waitbar(0,'仿真时间');
for i = 1:simuDuration
    waitbar(i/simuDuration,bar1);
    for j = 1:serviceType
        UserNumPerSecond = poissrnd(lambda(j),1,1);
%        totalUser = totalUser + UserNumPerSecond;

        if UserNumPerSecond ~= 0
            for k = 1:UserNumPerSecond
                userIndex = userIndex + 1;
                userInfo(userIndex,1) = i;     % 每个用户激活的开始时间
                userInfo(userIndex,2) = i + floor(exprnd(CSserviceHoldtime(j),1,1));    % 每个用户的通信结束时间
                userInfo(userIndex,3) = rand(1)*(xmax-xmin) + xmin;
                userInfo(userIndex,4) = rand(1)*(ymax-ymin) + ymin;
            end;
        end;
    end;
    
    exitUserIndex = 0;
    for j = 1:userIndex
        if userInfo(j,2) > i
            exitUserIndex = exitUserIndex + 1;
            exitUser(exitUserIndex,1) = userInfo(j,3);
            exitUser(exitUserIndex,2) = userInfo(j,4);
        end;
    end;
    scatter(exitUser(:,1),exitUser(:,2));title('用户位置');
    axis([xmin xmax ymin ymax]);
    clear exitUser
 
end;
close(bar1);






    


⌨️ 快捷键说明

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