clear;clc;
width=30 %道路宽
rl=5*width/8; %左转虚拟车道
rr=1*width/8; %右转虚拟车道
drr=pi/2*rr;
dstr=width-sqrt(rl^2-(width/8)^2); %直行距离
dl=(acos(width/8/rl))*rl; %左拐距离
ck=1.8 ; %车宽
cl=3.8 ; %车长
ddstr=sqrt((rl+ck/2)^2-(width/8+ck/2)^2)-sqrt(rl^2-(width/8)^2);
ddl=(acos(width/8/rl)-acos((width/8+ck/2)/(rl+ck/2)))*rl;
sl=dl;
sstr=dstr;
onetime=160;
dmin=2;
azb=[];
bzb=[];
alcar=[]; %行车矩阵
arcar=[];
astrcar=[];
blcar=[];
brcar=[];
bstrcar=[];
cjjlal=[];
cjjlar=[];
cjjlastr=[];%车间距
cjjlbl=[];
cjjlbr=[];
cjjlbstr=[];%车间距
red=30;
yel=10;
val0=4 ; %a左行车速度(此处设未冲突速度)
var0=5 ; %a右行车速度(此处设未冲突速度)
vastr0=6 ; %a直行车速度(此处设未冲突速度)
vbl0=val0 ; %b左行车速度(此处设未冲突速度)
vbr0=var0 ; %b右行车速度(此处设未冲突速度)
vbstr0= vastr0 ; %b直行车速度(此处设未冲突速度)
val=[];
val(1)=val0 ;
var=[];
var(1)=var0 ;
vastr=[] ;
vastr(1)=vastr0;
vbl=[] ;
vbl(1)=vbl0;
vbr=[];
vbr(1)=vbr0 ;
vbstr=[]
vbstr(1)=vbstr0 ;
dt=0.1 ; %时间步长
alcar(1)=val*dt;
arcar(1)=vbr(1)*dt;
astrcar(1)=vastr(1)*dt;
blcar(1)=vbl(1)*dt;
brcar(1)=vbr(1)*dt;
bstrcar(1)=vbstr(1)*dt;
T=dt;
sumal=1;
sumar=1;
sumastr=1;
sumbl=1;
sumbr=1;
sumbstr=1;
kal=1;
kar=1;
kastr=1;
kbl=1;
kbr=1;
kbstr=1;
dertal=0;
dertas=0;
%外部条件参数===========================================================================================================
yctime=0.5;%加速延迟时间
jsxs=0.7;%减速系数
ajia=8;%最大加速度
ajian=8;%最大减速度
azxgl=1;
ayzxgl=1;
bzxgl=1;
byzxgl=1;
pro=0.02;
sigma=1;
n=20;%画图中的模拟车!!!!!!!!!!!!!!!!!!!!!
ttt=0.000000001;
while T<=onetime
T=T+dt;
lor=mod(floor(T/(red+yel)),2);
goy=mod(T,red+yel);
%虚拟交警================================================================================================================
if kal~=0
cjjlal(1)=0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555
end
if kar~=0
cjjlar(1)=0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555
end
if kastr~=0
cjjlastr(1)=0;%%%%%%%%%%%%%%%%%%%%%%5
end
if kbl~=0
cjjlbl(1)=0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555
end
if kbr~=0
cjjlbr(1)=0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555
end
if kbstr~=0
cjjlbstr(1)=0;%%%%%%%%%%%%%%%%%%%%%%5
end
if kbl~=0&&kastr~=0
pbl=dl-blcar(1)-sl;
pastr=dstr-astrcar(1)-sstr;
if pbl<=0&&pastr<=0
ttsl=(dl-blcar(1)-ddl)/vbl(1)+dertal;
ttsstr=(dstr-astrcar(1)-ddstr)/vastr(1)+dertas;
if(ttsstr<=ttsl)
if vastr(1)<vastr0
vastr(1)=min(vastr(1)+ajia*dt,vastr0);
end
xvbl=[(dl-blcar(1)-ddl)/((dstr-astrcar(1)+ddstr+cl)/vastr(1)),vbl0];
vbl(1)=min(xvbl);
jishi1=dt;
elseif(ttsstr>ttsl)
if vbl(1)<vbl0
vbl(1)=min(vbl(1)+ajia*dt,vbl0);
end
xvastr=[(dstr-astrcar(1)-ddstr)/((dl-blcar(1)+ddl+cl)/vbl(1)),vastr0];
vastr(1)=min(xvastr);
jishi1=dt;
end
end
end
if kal~=0
cjjlal(1)=0;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555
end
if kbstr~=0
cjjlbstr(1)=0;%%%%%%%%%%%%%%%%%%%%%%5
end
if kal~=0&&kbstr~=0
pal=dl-alcar(1)-sl;
pbstr=dstr-bstrcar(1)-sstr;
if pal<=0&&pbstr<=0
ttsl=(dl-alcar(1)-ddl)/val(1)+dertal;
ttsstr=(dstr-bstrcar(1)-ddstr)/vbstr(1)+dertas;
if(ttsstr<=ttsl)
if vbstr(1)<vbstr0
vbstr(1)=min(vbstr(1)+ajia*dt,vbstr0);
end
xval=[(dl-alcar(1)-ddl)/((dstr-bstrcar(1)+ddstr+cl)/vbstr(1)),val0];
val(1)=min(xval);
jishi1=dt;
elseif(ttsstr>ttsl)
if val(1)<val0
val(1)=min(val(1)+ajia*dt,val0);
end
xvbstr=[(dstr-bstrcar(1)-ddstr)/((dl-alcar(1)+ddl+cl)/val(1)),vbstr0];
vbstr(1)=min(xvbstr);
jishi1=dt;
end
end
end
if kar~=0
if var(1)<var0
var(1)=min(var(1)+ajia*dt,var0);
end
end
if kbr~=0
if vbr(1)<vbr0
vbr(1)=min(vbr(1)+ajia*dt,vbr0);
end
end
%虚拟交警================================================================================================================
if goy<=red
%a左行车辆运行段================================================================================================================
ppal=rand;
if kal==0
if ppal<=azxgl
val(1)=val0 ;
alcar(kal+1)=val(1)*dt;
kal=kal+1;
cjjlal(kal)=0;
end
else
for i=1:kal
if i~=1
cjjlal(i)=alcar(i-1)-alcar(i);
if cjjlal(i)-(normrnd(cheju(val(i-1)),sigma))<0
val(i)=max(val(i)-ajian*dt,jsxs*val(i-1));
else
val(i)=min(val(i)+ajia*dt,val(i-1)+(cjjlal(i)-(normrnd(cheju(val(i-1)),sigma)))/yctime);
end
end
alcar(i)=alcar(i)+val(i)*dt;
end
if alcar(kal)>=(normrnd(cheju(val(kal)),sigma))+val(kal)*dt
if ppal<=azxgl
alcar(kal+1)=val(kal)*dt;
val(kal+1)=val(kal);%%%%%%%%%%%%%%%%%%%%%%%%%%55
cjjlal(kal+1)=(normrnd(cheju(val(kal)),sigma));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% all=normrnd(all0,sigma);
end
kal=length(alcar);
end
%a右行车辆运行段================================================================================================================
ppasr=rand;
pa=rand;
if kar==0
if ppasr<=ayzxgl
if pa<=pro
if kastr==0||astrcar(kastr)>=cl+dmin
var(1)=var0 ;
arcar(kar+1)=var(1)*dt;
kar=kar+1;
cjjlar(kar)=0;%%%%%%%%%%%%%%%%%%%%%%%%
end
end
end
else
for i=1:kar
if i~=1
cjjlar(i)=arcar(i-1)-arcar(i);
if cjjlar(i)-(normrnd(cheju(var(i-1)),sigma))<0
% if cjjlar(i)=cl+twj
var(i)=max(var(i)-ajian*dt,jsxs*var(i-1));
else
var(i)=min(var(i)+ajia*dt,var(i-1)+(cjjlar(i)-normrnd(cheju(var(i-1)),sigma))/yctime);
end
end
arcar(i)=arcar(i)+var(i)*dt;
end
if arcar(kar)>=(normrnd(cheju(var(kar)),sigma))+var(kar)*dt&&(kastr==0||astrcar(kastr)>=cl+dmin)
if ppasr<=ayzxgl
if pa<=pro
arcar(kar+1)=var(kar)*dt;
var(kar+1)=var(kar);
cjjlar(kar+1)=(normrnd(cheju(var(kar)),sigma));%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
阿里matlab建模师
- 粉丝: 4765
- 资源: 2880
最新资源
- Refrig-RefrigerationBoxLoads.exe
- AHTTv510.pdf
- TRANE.zip
- 开利PLV IPLV计算软件ECAT-PLV120.zip
- Copeland-Refrigeration-Manuals.zip
- 汽车空调制冷系统匹配设计1.pdf
- 换热器选型GreenheckCoilSelection.zip
- SystemSyzerPsychrometric .exe
- 汽车空调制冷系统匹配研究1.pdf
- 混合动力汽车空调系统研究及优化1.pdf
- 电动汽车热泵空调系统匹配特性研究1.pdf
- 基于互信息(MI)的回归数据特征选择算法 matlab代码
- 纯电动汽车动力电池与空调联合热管理仿真研究1.pdf
- 某车型汽车空调系统匹配研究1.pdf
- 汽车空调制冷系统匹配计算及研究1.pdf
- 商用车驻车空调系统性能分与实验研究1.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈