双圆道交通流ca模型matlab程序

双圆道交通流ca模型matlab程序

ID:22291474

大小:77.00 KB

页数:5页

时间:2018-10-28

双圆道交通流ca模型matlab程序_第1页
双圆道交通流ca模型matlab程序_第2页
双圆道交通流ca模型matlab程序_第3页
双圆道交通流ca模型matlab程序_第4页
双圆道交通流ca模型matlab程序_第5页
资源描述:

《双圆道交通流ca模型matlab程序》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、%functionfrho,flux,vmeanl=ns2(rho,p,L,tmax)%注意:主函数一定不能像子函数一样以function开头。此程序为含控制按钮NS模型改编双车道,无换道。%NS:ThisscriptimplementstheNagelSchreckenbergcellularautomatabased%trafficmodel.CarmoveforwardgovernedbyNSalgorithm:%%1.Acceleration.Ifthevehiclecanspeedupwithouthittingthespeed

2、%limitvmaxitwilladdonetoitsvelocity,vn-〉vn+1.Otherwise,%thevehiclehasconstantspeed,vn鉸?vn.%%2.Collisionprevention.Ifthedistancebetweenthevehicleandthecar%aheadofit,dn,islessthanorequaltovn,i.e.thenthvehicle%willcollideifitdoesn'tslowdown,thenvn紋?dn蓥?1.%%3.Randomslowing.Ve

3、hiclesoftenslowfornon-trafficreasons(cell%phones,coffeemugs,evenlaptops)anddriversoccasionallymake%irrationalchoices.Withsomeprobabilitypbrake,vn=?vn-1,%presumingvn>0.%%4.Vehiclemovement.Thevehiclesaredeterministicallymovedbytheir%velocities,xn->xn+vn.%%USAGE:flux=ns(rho,

4、p,L,tmax,isdraw)%rho=densityofthetraffic%p=probabilityofrandombraking%L=lengthoftheload%tmax=numberoftheiterations%animation=ifshowtheanimation(动M)ofthetraffic%spacetime=ifplotthespace-timeafterthesimuationended.%flux=fluxofthetraffic%%zhoulvwen:zhou.lv.wen@gmail.comrho=0

5、.25;p=0.25;L=100;tmax=100;i=0;%=========================%buildtheGUI%definetheplotbuttonplotbutton=uicontrol(style’,’pushbutton’,…’string'/Run’,...•fontsizef,12,…'position',[60,400,50,20],...'callback','run=l;');%definethestopbuttonerasebutton=uicontrol(,style7pushbutton

6、...’string’,Stop1,...’fontsize’,12,…'position1,[120,400,50,20],...'callback','freeze=lO/O=============================================%definetheQuitbuttonquitbutton=uicontrol(’style’,’pushbutton’”..•string','Quit•,…•fontsize’,12,…'positional80,400,50,20],...,callback,st

7、op=1;close;’);O/O=============================================vmax=5;%maximunspeed%placeadistributionwithdensitynear=round(L*rho);rho=ncar/L;xl=sort(randsample(1:L,near));x2=sort(randsample(1:L,near));x=[xl;x2];%randsample(l:L,near),从1-100产生25个随机整数,sort排序默认升序v=vmax*ones(2

8、,ncar);%starteveryoneinitiallyatvmax[hl,h2]=plotcirc(L,x,0.1);flux=0;%numberofcarsthatpassthroug

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。