資源簡介
這個是我參加2017年美賽數(shù)模借鑒了別人寫的部分代碼,自己寫的元胞自動機代碼, 大家可以下載了看看哦~, 如果有什么問題歡迎聯(lián)系我~感謝下載喵~

代碼片段和文件信息
clc;
close?all;
%=====================GUI部分========================================
plotbutton=uicontrol(‘style‘‘pushbutton‘...
???‘string‘‘Run‘?...
???‘fontsize‘12?...
???‘position‘[1004005020]?...
???‘callback‘?‘run=1;‘);
%define?the?stop?button
erasebutton=uicontrol(‘style‘‘pushbutton‘...
???‘string‘‘Stop‘?...
???‘fontsize‘12?...
???‘position‘[2004005020]?...
???‘callback‘‘freeze=1;‘);
%define?the?Quit?button
quitbutton=uicontrol(‘style‘‘pushbutton‘...
???‘string‘‘Quit‘?...
???‘fontsize‘12?...
???‘position‘[3004005020]?...
???‘callback‘‘stop=1;close;‘);
number?=?uicontrol(‘style‘‘text‘?...
????‘string‘‘1‘?...
???‘fontsize‘12?...
???‘position‘[204005020]);
%=======================初始化車道量======================================
B=2;?????????????%The?number?of?the?lanes
roadlength=50;??%The?length?of?the?simulating?highways
merge?=?30;
barrier?=?10;
scale?=?0.1;
switch_ratio?=?0.9;
road=zeros(roadlengthB+2);
v=zeros(roadlengthB+2);
road(merge:roadlength2)?=?-1;??
road(1:roadlength[1B+2])=-1;
h?=?imagesc(road);
set(h?‘erasemode‘?‘none‘)
axis?equal
axis?tight
vmax?=?zeros(502);
probc=0.1;??????????%?車輛的密度
probv=[0.330.661];??????%?兩種車流的密度分布
probslow=0.1;???????%?隨機慢化的概率
VTypes=[123];?????%?道路上一共有幾種最大速度不同的車輛速度是什么
[roadvvmax]=new_cars(roadvprobcprobvVTypesvmaxscale);%一開始就在車道上布置車輛,做周期循環(huán)駕駛,也方便觀察流量密度之間的關(guān)系
ROAD=rot90(road2);
h=show_road(ROADh0.1);
%======================進行迭代========================================
run?=?0;
stop?=?0;
freeze?=?0;
while(stop==0)
????if?(run==1)
????????[vLUPLDOWN]=road_count(roadv);
????????[roadvvmax]=switch_lane(roadvvmaxLUPLDOWNbarrierswitch_ratio);
????????[roadvvmax]=move_forward(roadvvmaxprobslowmerge);
????????[roadvvmax]=new_cars(roadvprobcprobvVTypesvmaxscale);
????????ROAD=rot90(road2);
????????h=show_road(ROADh0.1);
????end
????if?(freeze==1)
????????run?=?0;
????????freeze?=?0;
????end
????drawnow
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2551??2017-01-23?23:42??Cellular2.m
?????文件????????6933??2017-01-23?18:27??move_forward.m
?????文件?????????760??2017-01-23?15:54??new_cars.m
?????文件????????1314??2017-01-23?17:41??road_count.m
?????文件?????????645??2017-01-22?13:26??show_road.m
?????文件????????2337??2017-01-23?18:50??switch_lane.m
?????文件????????2129??2017-01-23?03:18??Cellular.m
評論
共有 條評論