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

📄 mobmove.m

📁 这是一个基于matlab/RUNE环境的移动通信网络仿真程序包
💻 M
字号:
function [xym,xyv] = mobmove(xym,xyv,amean,vmean,dt,rombvec)
% DESCRIPTION [xym,xyv] = mobmove(xym,xyv,amean,vmean,dt,rombvec)
%  Move and initiate position of users.
% INPUT
%  xym --     Complex position of users possibly. NaN for users that have not yet
%             received any position and thus are regarded as new.
%  xyv --     Complex speed [m/s].
%  amean --   Average acceleration of mobiles.
%  vmean --   Mean speed of mobiles. 
%  dt --      Time interval since last call to this routine.
%  rombvec -- Two complex vectors determining the area within which 
%             mobiles are folded.
%%%%%%%%%% OUTPUT WILL BE THE NEW POSITION AND NEW SPEED IN TERMS OF COORDINATES
%  xym --     New position. 
%  xyv --     New speed.

%%If the probability is less that 60% then it will go straight otherwise it
%%will turn randomly

rand;
if rand<0.6
    par.vmean=1;
    par.amean=0;
    raa=1;
    
    

else
    par.vmean=1;
    par.amean=-1*rand;    
raa = exp(-mdiv(dt.*amean,vmean));
end


% Move users.

raa = exp(-mdiv(dt.*amean,vmean));
%raa=1;
% raa is the correlation between the new and the old xyv
% and does not impact the variance.
xyv = xyv.*raa+sqrt(1-raa.^2).*vmean/sqrt(pi/2).*irandn(size(xyv));   %here i have to disable this line in order to take a linear move
xym = xym + xyv.*dt;

% Give new mobiles speed and position.
newones = isnan(xym);

% Generate position and wrap into simulated area.
xym(newones)= 0;
if exist('rombvec','var')
 if all(isfinite(rombvec))
  xym(newones) = rand(size(xyv(newones),1),2)*rombvec(:);
  xym = wrapinto(xym+mean(rombvec),rombvec,'romb')-mean(rombvec);
 end
end
% Init speed.
xyv(newones) = vmean/sqrt(pi/2).*irandn(size(xyv(newones))); 

xym = xym(:); % Make sure only first dimension.
xyv = xyv(:);

⌨️ 快捷键说明

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