clear
G = 5:0.01:0.1;
n=length(G);
t0=0.5;
i=0;
u=0;
b=0;
tb = 0;
tu=0;
ti=0;
for j = 1:length(G)
r = exprnd(G(j),1,n);
if r(j)1;
tb = r(j)+t0;
elseif r(j)>t0
u=u+1;
ti =ti+(r(j)-t0);
else
b=b+1;
end
tu = u*t0;
Su(j) = tu/(ti+tu+tb);
Sb(j) = tb/(ti+tu+tb);
Si(j) = ti/(ti+tu+tb);
T = (ti+tu+tb);
end
G=1./G
plot(G,Su,'g',G,Sb,'r-',G,Si,'b-')
legend('发送成功率u','碰撞率B','空闲率');