📄 times_dynamically.m
字号:
function [q,delay_nd] = times_dynamically(speed,x,y,ap,rx_threshold)
direction = pi/4;
counter = 0;
t_min = 5;
t_max = 15;
d_mt_ap = sqrt((x-ap.x)^2+(y-ap.y)^2);
for times = 1:300
d_ap = sqrt((x-ap.x)^2+(y-ap.y)^2);
rss = ap.pt*(ap.antenna^2)/(d_ap^4);
if (rss >= rx_threshold)
counter = counter + 1;
else
counter = 0;
end
if (counter == 5)
q = times;
%journal delay_nd = (wlan_boundary - d_wlan)/speed
%delay_nd = (ap.r- d_ap)/speed; % the delay between the actual
%discovering time and the supposed discovering time
distance = sqrt(x^2+y^2);
delay_nd = distance/speed; % time spent from the mt's starting moving to mt's discovering WLAN.
break
end
t_int = t_min + (t_max - t_min)*(1 - rss/rx_threshold);
if (t_int > t_max)
t_int = t_max;
end
if (t_int < t_min)
t_int = t_min;
end
d = speed*t_int;
x = x+d*sin(direction);
y = y+d*cos(direction);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -