ODE45 - Modeling GHR Microspic Car following Model

2 ビュー (過去 30 日間)
Khalilullah Mayar
Khalilullah Mayar 2019 年 9 月 18 日
コメント済み: Khalilullah Mayar 2019 年 9 月 25 日
Hi everyone,
Can someone help with modeling the following Gazis–Herman–Rothery (GHR) model in Matlab:
Model.jpg
I have the data for the leader car stored in mytrafficdata5 files as folllows:
Model 2.jpg
I have edited the following code from a similar model (OVM). A difference here is the time lag (tau=1 sec) between the leader and follower vehicles. I was unable to run the code and wonder if someone can help to fix it as per the given model. Thanks
function basic_ghr
% y is velocity
% t is time
% Using interpolant for distance
close all;
load mytrafficdata5;
time_vector = Time_t;
init_speed = 0;
dist_vector = Distance_n;
vel_vector = Velocity_n
% dist_interp = interp1(time_vector, dist_vector,);
% vel_interp = interp1(time_vector, vel_vector,);
F_time = time_vector(end);
[T,Y] = ...
ode45( @(t,y) ...
some_system(t,y,time_vector,dist_vector),[0,F_time],init_speed);
plot(T,Y(:,1),'b-',time_vector,vel_vector,'r--')
legend('By GHR','Real Velocity')
title('Comparisam of velocity with time bewteen Real Data Set VS. GHR model')
xlabel('Time')
ylabel('Velocity (m/sec)')
function dy = some_system(t,y,time_vector,dist_vector, vel_vector)
c = 125;
m = 0.2;
l = 1.6;
%%%%%%%%%%%%%%%%%
% Using interpolant for distance and velocity
dist_interp = interp1(time_vector, dist_vector, t);
vel_interp = interp1(time_vector, vel_vector, t);
dy = c *((y)^m)/(vel_interp)^l))*(dist_interp);
  2 件のコメント
Stephan
Stephan 2019 年 9 月 18 日
Attaching the data would help
Khalilullah Mayar
Khalilullah Mayar 2019 年 9 月 18 日
I have attached the data file now. Not quite sure if the interp1 function was the right thing to deal with delta x and delta v quantities in this model.

サインインしてコメントする。

採用された回答

Stephan
Stephan 2019 年 9 月 18 日
編集済み: Stephan 2019 年 9 月 18 日
This code runs, but still has a problem:
load mytrafficdata5;
basic_ghr(Distance_n,Time_t,Velocity_n)
function basic_ghr(Distance_n,Time_t,Velocity_n)
% y is velocity
% t is time
% Using interpolant for distance
close all;
time_vector = Time_t;
init_speed = 0;
dist_vector = Distance_n;
vel_vector = Velocity_n;
% dist_interp = interp1(time_vector, dist_vector,);
% vel_interp = interp1(time_vector, vel_vector,);
F_time = time_vector(end);
[T,Y] = ode45(@(t,y)some_system(t,y),[0,F_time],init_speed);
plot(T,Y(:,1),'b-',time_vector,vel_vector,'r--')
legend('By GHR','Real Velocity')
title('Comparisam of velocity with time bewteen Real Data Set VS. GHR model')
xlabel('Time')
ylabel('Velocity (m/sec)')
function dy = some_system(t,y)
c = 125;
m = 0.2;
l = 1.6;
%%%%%%%%%%%%%%%%%
% Using interpolant for distance and velocity
dist_interp = interp1(time_vector, dist_vector, t);
vel_interp = interp1(time_vector, vel_vector, t);
dy = c *(y^m)/(vel_interp)^l*(dist_interp);
end
end
The result of Y(:,1) is a vector of one zero and then all NaN - so you will have to check your equation.
  7 件のコメント
Khalilullah Mayar
Khalilullah Mayar 2019 年 9 月 23 日
Thanks Stephan, that was helpul.
Khalilullah Mayar
Khalilullah Mayar 2019 年 9 月 25 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by