Demo entry 6763223

Linesystem

   

Submitted by anonymous on Oct 20, 2018 at 13:39
Language: Matlab. Code size: 605 Bytes.

%排队系统的仿真
a = zeros(1,100);
%到达车数的向量   
 a(24:53) = 1;
 a(54:83) = 2;
 a(84:93) = 3;
 a(94:98) = 4;
 a(99:100) = 5;
Table = zeros(50000,6);
j = 1;
while j <= 50000
    num = randperm(100,1);%随机数
    Table(j,1) = j;%日期
    Table(j,2) = num;%随机数
    Table(j,3) = a(num);%到达数
    %需要卸货车数
    Table(1,4) = Table(1,3);
    if j>1
        Table(j,4) = Table(j,3) + Table(j-1,6);
    end
    %卸货车数
    if Table(j,4)<=2
        Table(j,5) = Table(j,4);
    else
        Table(j,5) = 2;
    end
    Table(j,6) = Table(j,4)-Table(j,5);
    j = j+1;
end
mean(Table(:,3))
mean(Table(:,6))

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).