数学建模——排队论问题

代码:

clear 
rand('state',sum(100*clock)); 
n=50000; 
m=2 
a1=rand(n,1); 
a2=a1; %a2初始化
a2(find(a1<0.23))=0; 
a2(find(0.23<=a1&a1<0.53))=1; 
a2(find(0.53<=a1&a1<0.83))=2; 
a2(find(0.83<=a1&a1<0.93),1)=3; 
a2(find(0.93<=a1&a1<0.98),1)=4; 
a2(find(a1>=0.98))=5; 
a3=zeros(n,1);a4=zeros(n,1);a5=zeros(n,1); %a2初始化
a3(1)=a2(1); 
if a3(1)<=m 
 a4(1)=a3(1);a5(1)=0; 
else 
-151- 
 a4(1)=m;a5(1)=a2(1)-m; 
end 
for i=2:n 
 a3(i)=a2(i)+a5(i-1); 
 if a3(i)<=m 
 a4(i)=a3(i);a5(i)=0; 
 else 
 a4(i)=m;a5(i)=a3(i)-m; 
 end 
end 
a=[a1,a2,a3,a4,a5]; 
sum(a)/n

少年不被楼层误,余生不羁尽自由。
加油,加油!

你可能感兴趣的:(自我学习)