IDM Car following microspoic model
Mostrar comentarios más antiguos
Hi everyone,
Can someone help why the following code couldn't run? It's an IDM car following microscopic model introduced by the equations and parameters below:

load mytrafficdata5;
someidmm(Time_t,Distance_n,Velocity_n)
function someidmm(Time_t,Distance_n,Velocity_n)
% y is velocity
% t is time
% Using interpolant for distance and velocity
close all;
time_vector = Time_t;
init_speed = 0.2;
vel_vector = Velocity_n;
Dist_vector= Distance_n;
F_time = time_vector(end);
figure (1);
[T,Y] = ode45(@(t,y)idm5(t,y),[0,F_time],init_speed);
plot(T,Y(:,1),'b-',time_vector,vel_vector,'r--')
legend('By IDM','Real Velocity')
xlabel('Time')
ylabel('Velocity (m/sec)')
legend('Location','best')
function dy = idm5(t,y)
% parameters
x0_dot =30; % unit is m/sec
delta =4;
a=0.3;
b= 3;
s0=2;
Th=1.5; %time headway=1.5 sec
k = 1/(2*sqrt(a*b));
lc=5;
dist_interp = interp1(time_vector, Dist_vector, t);
vel_interp = interp1(time_vector, vel_vector, t);
xn = dist_interp;
Delta_v = y-vel_interp;
Dis = int(y,[0 F_time]) % integratoin of y (velocity) to get distance
s = xn-Dis - lc;
s_star = s0 + max(0,y*Th + y*Delta_v*k);
%-main system-- %
dy = a*(1 - (y/x0_dot).^delta - (s_star/s).^2);
end
end
Data for the leader car is attached (mytrafficdata5.mat)
Note: I believe there might an issue with the integration line (Dis = int(y,[0 F_time]) % integratoin of y (velocity) to get distance).
1 comentario
Khalilullah Mayar
el 24 de Sept. de 2019
Respuesta aceptada
Más respuestas (1)
Mouncef
el 10 de Jun. de 2023
0 votos
can you explain this simulation ?
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!