📄 chap7b_func.m
字号:
%P7-17(b)%Statistics of user mobility patterns are important for designing efficient hand-off %management schemes. Due to the high degree of randomness in user movement patterns, %it is in general a very complex task to obtain the statis-tics. Certain assumptions %on user movements need to be made to simplify the task, even by computer simulation.%Consider a hexagonal cell with cell radius R=5km. Assume that mobile users are %uniformly distributed in the cell and all the mobiles are active. Over a time period %of T, each mobile travels in a straight line at a constant velocity. The initial %direction is uniformly distributed over[0,2pi]. The direction change in the next %period is uniformly distributed over [-alpha, alpha], where alpha <= pi/2. The %velocity can be modeled as a Gaussian random variable with mean speed u and standard %deviation std (the negative values are unlikely when mean speed >> standard deviation%and are to be replaced by 0), and is independent from period to period. The movement %pattern of each mobile is independent of those of any other mobiles. We want to obtain %the following mobility statistics based on computer simulation.%(b)Given T = 1 minute, mean speed = 40 km/hour, standard deviation = 5km/hour, find %the mean sojourn time for alpha equal to pi/6, pi/4 and pi/2 respectively. Comment %on the effect of alpha.function chap7b_func (action)handle = findobj(gcbf, 'Tag', 'mean');mean = eval(get(handle,'String'));handle = findobj(gcbf, 'Tag', 'std');std = eval(get(handle, 'String'));handle = findobj(gcbf, 'Tag', 'R');R = eval(get(handle, 'String'));handle = findobj(gcbf, 'Tag', 'N');N = eval(get(handle, 'String'));%parameterssigma = std/60; %km/minu = mean/60; %km/minalpha(1:3) = [pi/6, pi/4, pi/2];for i = 1:3%initial direction uniformly distributed between 0 to 2piD0 = 2* pi*rand(1, N);%initial mobile user locationsr = R*rand(1, N);deg = 360*rand(1, N);x = r.*cos(deg);y = r.*sin(deg);T = 0;for j= 1:N Done = 0; D = D0(j); count = 0; curr_x = x(j); curr_y = y(j); while (Done == 0 & count < 1000) count = count + 1; %time for user to reach cell boundary %direction change in next period uniformly distributed between -alpha to alpha delta_D = 2* alpha(i) * rand(1) - alpha(i); %velocity modeled by a Gaussian random distribution V = sigma * randn(1) + u; delta_x = V* cos(D); delta_y = V* sin(D); curr_x = curr_x + delta_x; curr_y = curr_y + delta_y; L = sqrt(curr_x^2 + curr_y^2); %distance from Base Station; if (L >= R) %mobile user outside of cell coverage Done = 1; else D = D + delta_D; end end T = T + count; %total time for all users to reach cell boundaryendSt(i) = T/N; %mean Sojourn time.endplot(alpha, St, 'b+-');xlabel('alpha');ylabel('Sojourn Time (min)');grid on;return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -