資源簡介
這是05年美模O獎的關于交通流的matlab代碼,實用性很強,也便于大家學習!

代碼片段和文件信息
clear;
figure(‘position‘[50?132?900?400]‘doublebuffer‘‘on‘)?
W?=?[];
for?j=0:7;
B?=?6+j;?%number?booths
L?=?6;?%number?lanes?in?highway?before?and?after?plaza
T?=?1;?%?#?hrs?to?simulate
global?plazalength;
plazalength?=?101;
plaza?=?create_plaza(BL);
set(gcf‘resize‘‘off‘)
PLAZA=rot90(plaza);
PLAZAA=0.8*ones(401013);
PLAZA(PLAZA==1)=2;
PLAZA(PLAZA==0)=1;
PLAZA(PLAZA==2)=0;
PLAZA(PLAZA~=0&PLAZA~=1)=0.8;
PLAZAA(20-ceil(B/2):21+ceil(B/2):1)=PLAZA;
PLAZAA(20-ceil(B/2):21+ceil(B/2):2)=PLAZA;
PLAZAA(20-ceil(B/2):21+ceil(B/2):3)=PLAZA;
H=image(PLAZAA);
axis?off
entry_vector?=?create_entry(TL);
waiting_time?=?0;
output?=?0;
for?i?=?1:T*1440
plaza?=?move_forward(plaza);?%move?cars?forward
plaza?=?new_cars(B?L?plaza?entry_vector(1i));?%allow?new?cars?to?enter
plaza?=?switch_lanes(plaza);?%allow?lane?changes
waiting_time?=?waiting_time?+?compute_wait(plaza);?%compute?waiting?time?during?timestep?i
output?=?output?+?compute_output(plaza);
plaza?=?clear_boundary(plaza);
PLAZA=rot90(plaza);
PLAZA(PLAZA==1)=2;
PLAZA(PLAZA==0)=1;
PLAZA(PLAZA==2)=0;
PLAZA(PLAZA~=0&PLAZA~=1)=0.8;
PLAZAA(20-ceil(B/2):21+ceil(B/2):1)=PLAZA;
PLAZAA(20-ceil(B/2):21+ceil(B/2):2)=PLAZA;
PLAZAA(20-ceil(B/2):21+ceil(B/2):3)=PLAZA;
plaza50=PLAZAA(:501);plaza50(plaza50==1)=0;PLAZAA(:502)=plaza50;PLAZAA(:503)=plaza50;
set(H‘CData‘PLAZAA);
set(gcf‘position‘[50?132?900?400])
pause(0.01)
end
plaza;
W=[W?waiting_time]
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1478??2016-07-26?18:01??The?Booth?Tolls?for?Thee\cellular.m
?????文件????????135??2016-07-26?18:01??The?Booth?Tolls?for?Thee\clear_boundary.m
?????文件????????126??2016-07-26?18:01??The?Booth?Tolls?for?Thee\compute_output.m
?????文件????????137??2016-07-26?18:01??The?Booth?Tolls?for?Thee\compute_wait.m
?????文件????????521??2016-07-26?18:01??The?Booth?Tolls?for?Thee\create_entry.m
?????文件????????939??2016-07-26?18:01??The?Booth?Tolls?for?Thee\create_plaza.m
?????文件???????1215??2016-07-26?18:01??The?Booth?Tolls?for?Thee\move_forward.m
?????文件????????259??2016-07-26?18:01??The?Booth?Tolls?for?Thee\new_cars.m
?????文件???????1107??2016-07-26?18:01??The?Booth?Tolls?for?Thee\switch_lanes.asv
?????文件???????1106??2016-07-26?18:01??The?Booth?Tolls?for?Thee\switch_lanes.m
?????文件?????????17??2016-07-26?18:01??The?Booth?Tolls?for?Thee\說明.txt
?????目錄??????????0??2017-03-17?11:17??The?Booth?Tolls?for?Thee
-----------?---------??----------?-----??----
?????????????????7040????????????????????12
- 上一篇:相位調制 matlab
- 下一篇:matlab圖像邊緣檢測sobel算子梯度圖像
評論
共有 條評論