⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reliability4.m

📁 无线传感器网络的可靠路由算法
💻 M
字号:
o=zeros(9,7);p=0.2628;
for l=1:9
    x=0;
    for k=1:7
        x=x+1;
        suc=0;
        s=0;
        fail=0;
        for i=1:1000
            d=0;
            for h=1:5
                if d==0
                   v(h)=0;
                   count=0;
                   count1=0;
                   m=0;
                   while v(h)==0 && m<k
                         for j=count+1:8
                             s=s+1;
                             a=rand();
                             if a>p
                                count=count+1;
                             end
                         end
                         for j=8+count1:8+l-1
                             s=s+1;
                             a=rand();
                             if a>p
                                count1=count1+1;
                             end
                         end
                         if count1+count>=8
                            v(h)=1;
                         else
                             m=m+1;
                         end
                   end
                   if m>=k
                       d=1;
                       fail=fail+1;
                   end
                end
            end
            if d==0
                suc=suc+1;
            end
        end
        o(l,x)=s/5/suc;
    end
end
i=[0:1:6];
plot(i,o(1,:),'-o',i,o(2,:),'-*',i,o(3,:),'-+',i,o(4,:),'-d',i,o(5,:),'-p',i,o(6,:),'-s',i,o(7,:),'-x',i,o(8,:),'-.',i,o(9,:),'-h')
 axis([0,6,0,120]);
legend 0 1 2 3 4 5 6 7 8
xlabel('maximum number of retransmission');
ylabel('successful rate');
grid;

⌨️ 快捷键说明

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