我正在为 for 循环进行模拟和代码
例如
IntervalInterArrivalTime = [2 3 4 5] //user input
CDF = [250 500 750 1000] // this is the probability but multiply 1000 to alculate the range
randInterArrival = [991 351 754 823] // this is pc random generated number so each time wwill be different
lengthCDF = length(CDF); // length of the CDF which in this case is =4
period = 0;
我想要做的 for 循环是程序将使用 CDF 和 IntervalArrivalTime 检查 randInterArrival 的范围。例如:
如果 randInterArrival >0 且 <= CDF(1) ,则 period 将为 IntervalInterArrivalTime(1)
否则,如果 randInterArrival > CDF(1) 和 <= CDF(2) ,则周期将为 IntervalInterArrival(2)
否则,如果 randInterArrival > CDF(2) 和 <= CDF(3) ,则周期将为 IntervalInterArrival(3)
否则,如果 randInterArrival > CDF(3) 和 <= CDF(4) ,则周期将为 IntervalInterArrival(4)
for i=1:lengthCDF
if randInterArrival(i)>0 && randInterArrival(i)< CDF(i)
period=IntervalInterArrivalTime(i)
else if randInterArrival(i)> CDF(i) % how to continued to write the statement out so that i can loop through all the items in the CDF and check which IntervalInterArrival() it is
% i stop here and dunno how to continued to loop through the CDF and check
end
end
希望大家能帮忙。提前致谢