?? mobmove.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 + -