times_periodically.m

来自「此程序为发表过的一篇IEEE PIMRC 的paper的程序代码。是关于异构无线」· M 代码 · 共 27 行

M
27
字号
function [p,delay_nd] = times_periodically(speed,x,y,ap,rx_threshold,t)

direction = pi/4;
counter = 0;
d_mt_ap = sqrt((x-ap.x)^2+(y-ap.y)^2);
%t = 7;

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)
        p = times;
        %delay_nd = (ap.r- d_ap)/speed;  % time spent from the mt start moving to discover WLAN.
        distance = sqrt(x^2+y^2);
        delay_nd = distance/speed;
        break;
    end
    d = speed*t;
    x = x+d*sin(direction);
    y = y+d*cos(direction);
end

⌨️ 快捷键说明

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