reliability3.asv

来自「无线传感器网络的可靠路由算法」· ASV 代码 · 共 66 行

ASV
66
字号
o=zeros(9,7);p=0.2628;
for l=1:9
    x=0;
    for k=1:7
        x=x+1;
        s=0;
        suc=0;
       for i=1:1000
            count=0;
            count1=0;
           for j=1:8
                v=1;
               for h=1:5
                    if v==1
                       s=s+1;
                       a=rand();
                       if a<p^k
                          v=0;
                       else
                           for m=1:k
                               if a<p^m
                                   s=s+1;
                               end
                           end
                       end
                    end
                end
                if v==1
                   count=count+1;
                end
            end
           for j=8:8+l-1
                v=1;
               for h=1:5
                   if v==1
                      s=s+1;
                      a=rand();
                      if a<p^k
                         v=0;
                     else
                           for m=1:k
                               if a<p^m
                                   s=s+1;
                               end
                           end
                      end
                   end
                end
                if v==1
                   count1=count1+1;
                end
            end
            if count1+count>=8
               suc=suc+8;
            else
                suc=suc+count;
            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,:),'-x',i,o(7,:),'.',i,o(8,:),'-o',i,o(9,:),'-+')
% axis([0,6,0,4]);
legend 0 1 2 3 4 5 6 7 8
grid;

⌨️ 快捷键说明

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