www.gusucode.com > DATA_Traffic源码程序 > DATA_Traffic源码程序/datatraffic.m

    clear all;
clc;
s1=0;
[d]=1000*[0 128 512 1024];
for u=1:10
    for t=1:20
        ton([u],[t])=0.35*randint(1,1,[0,10]);
    end;
end;
for u=1:10
    for t=1:20
        if((ton([u],[t])>=0)&(ton([u],[t])<=2))
            tond([u],[t])=(ton([u],[t]))*d(1);
        end;
        if((ton([u],[t])>=3)&(ton([u],[t])<=5))
            tond([u],[t])=(ton([u],[t]))*d(2);
        end;
        if((ton([u],[t])>=6)&(ton([u],[t])<=8))
            tond([u],[t])=(ton([u],[t]))*d(3);
        end;
        if((ton([u],[t])>=9)&(ton([u],[t])<=10))
            tond([u],[t])=(ton([u],[t]))*d(4);
        end;
    end;
end;
s1=0;
for i=1:20
    for u=1:10
        s1=(tond([u],[i]))+s1;
        totalon(i)=s1;
    end;
    s1=0;
end;
bar(totalon);
totalon
for i=1:20
    if(totalon(i)<=1.54*power(10,6))
        rem(i)=0;
    else
        rem(i)=totalon(i)-(1.54*power(10,6));
    end;
end;
rem
xlabel('Time');
ylabel('Traffic');
title('DATA TRAFFIC');