time=input('intervaltime='); %输入时间步,以0.1s为单位,每隔time时间画一条曲线
controllfactor=input('controllfactor='); %画曲线的条数
k=input('敏感系数k=');
k1=input('k1=');
k2=input('k2=');
k3=input('k3=');
t=1;
L=1500;
x=0:15:1485;
x(1)=10;
temp=x;
f=linspace(0,0,100);
v=linspace(0,0,100);
v=v+tanh(15);
temp_v=v;
a=1:100;
t_1=[];
pos_1=[];
T=linspace(0,0,100);
tt=0.1;
pp=1;
while pp<=controllfactor
while t<=time*pp
for j=1:100
if j==100
xd(j)=temp(1)-temp(100);
else
xd(j)=temp(j+1)-temp(j);
end
if xd(j)<0
xd(j)=L+xd(j);
end
% a(j)=tanh(xd(j)-2)+tanh(2)-temp_v(j);
if j==100
a(j)=k*((6.75+7.91*tanh(0.13*(xd(j)-5)-1.57))-temp_v(j))+k1*(temp_v(1)-temp_v(j))+k2*(temp_v(2)-temp_v(1))+k3*(temp_v(3)-temp_v(2));
elseif j==99
a(j)=k*((6.75+7.91*tanh(0.13*(xd(j)-5)-1.57))-temp_v(j))+k1*(temp_v(j+1)-temp_v(j))+k2*(temp_v(1)-temp_v(100))+k3*(temp_v(2)-temp_v(1));
elseif j==98
a(j)=k*((6.75+7.91*tanh(0.13*(xd(j)-5)-1.57))-temp_v(j))+k1*(temp_v(j+1)-temp_v(j))+k2*(temp_v(100)-temp_v(99))+k3*(temp_v(1)-temp_v(100));
else
a(j)=k*((6.75+7.91*tanh(0.13*(xd(j)-5)-1.57))-temp_v(j))+k1*(temp_v(j+1)-temp_v(j))+k2*(temp_v(j+2)-temp_v(j+1))+k3*(temp_v(j+3)-temp_v(j+2));
end
v(j)=temp_v(j)+a(j)*tt;
x(j)=temp(j)+temp_v(j)*tt+tt*tt*a(j)/2;
if x(j)>L
x(j)=x(j)-L;
end
end
temp=x;
temp_v=v;
% pos_1=x;
% for j=1:100
% plot(pos_1(j),t,'k.','MarkerSize',1);
% hold on;
% end
% T(t)=t;
t=t+1;
% if t==3000
% for q=1:100
% caa(q)=q;
% end
%
% plot(caa,v);
% hold on;
% end
end
car=[];
for p=1:100
car(p)=p;
end
T=linspace(0,0,100)+pp*time/10;%x轴的时间间隔为pp所乘的数字,本例为100s
plot3(T,car,v);
hold on;
% xlabel('车辆数');
% ylabel('速度');
pp=pp+1;
end
xlabel('时间(s)'),ylabel('车辆数'),zlabel('速度(m/s)');
threedimension.rar_matlab交通流_交通 matlab_交通 流_交通 matlab_交通流 mat
版权申诉
32 浏览量
2022-07-15
15:31:30
上传
评论
收藏 1KB RAR 举报
![avatar](https://profile-avatar.csdnimg.cn/823be93c18be4b9fa55c75bb75c369e0_weixin_42659791.jpg!1)
Kinonoyomeo
- 粉丝: 77
- 资源: 1万+
最新资源
- 数据库管理工具:dbeaver-ce-23.3.1-stable.x86-64.rpm
- AndroidOCR源码.zip
- 数据库管理工具:dbeaver-ce-23.3.0-x86-64-setup.exe
- 数据库管理工具:dbeaver-ce-23.3.0-stable.x86-64.rpm
- 数据库管理工具:dbeaver-ce-23.3.0-macos-x86-64.dmg
- 数据库管理工具:dbeaver-ce-23.3.0-macos-aarch64.dmg
- 数据库管理工具:dbeaver-ce-23.2.5-stable.x86-64.rpm
- 数据库管理工具:dbeaver-ce-23.2.5-macos-x86-64.dmg
- C语言面试应用详解教程
- 数据库管理工具:dbeaver-ce-23.2.5-macos-aarch64.dmg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
评论0