IDM Car following microspoic model
Show older comments
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 Comment
Khalilullah Mayar
on 24 Sep 2019
Accepted Answer
More Answers (1)
Mouncef
on 10 Jun 2023
0 votes
can you explain this simulation ?
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!