Question: MATLAB problem: Hello I have a question for a homework problem I am working on and need some help. So essentially the goal of the

MATLAB problem:

Hello I have a question for a homework problem I am working on and need some help. So essentially the goal of the homework is to create a funtion that uses the idm (intelligent driver model) and ode45 to simulate mulitple car's posistions after some time driving around a ring or circle (we were also given the option to model as though driving in a straight line aswell if it is easier). Here is the Idm formulas:

MATLAB problem: Hello I have a question for a homework problem I

what I have so far:

function idm clc; clear all; % IDM: Intellegent Driver model V0=28; % Desired sped in m/s T= 1.8; %following time in sec S0= 2; %Minimum gap distance in m a= 0.3; % acceleration of cars in m/s^2 b= 3; % Decceleration of cars in m/s^2 L= 5; %vehicle length delta= 4; % Acceleration exponent m=15; %minutes % unpack your variables array X tspan=[0 60*m]; mcars=5; %total cars X0=[1 2*mcars]; xinit= (0:mcars).*10; %initial posistions vinit= V0; %initial velocities [time, M]=ode45(@idm,tspan,[xinit;vinit]);

function rate = idm(t, X) % note that you can either use the length function to find mcars % or nest this inside your main function to share that variable between main and sub function x = X(1:mcars); % positions v = X(mcars+1:2*mcars); % velocities % loop over cars dv=a(1-(dx/V0).^delta-(sp/s).^2);%Idm formula for change in velocity sp=S0+dx.*T+(v.*dv)/(2*sqrt(a*b)); %Idm formula for dynamic braking for icar = 1:mcars if icar==1 dx(1)=v(1); dv(1)= v(1)- v(mcars); s= x(1)-x(mcars)-L; v(1)=V0; end % here you enter your Matlab code to apply the rate formulas for the IDM model % This will be a little different for line of cars vs ring road and will need special % consideration for the first car. dx(icar) = v(icar); dv(icar) = v(icar) - v(icar-1); s= x(icar)-x(icar-1)-L; end

% Pack the rate array rate(1:mcars) = dx; rate(mcars+1:2*mcars) = dv; rate = rate'; % convert from row to column end

end

The IDM model give the acceleration of a car by this equation: dy dt 7 where (2) The acceleration (eqn 1) is divided into a "desired" acceleration of a car on a free road ( al1-(/v)delta) and braking decelerations induced by the distance to the vehicle ahead (-s*/s) 2. The acceleration on a free road goes to zero when approaching the "desired speed" of v0. The constants a, b, T, and (delta) describe driver behavior (see table below). The braking term is based on a comparison between the "desired dynamical distance" s', and the actual gap s to the preceding vehicle. If the actual gap is approximatively equal to s , then the braking deceleration essentially compensates for the free acceleration part, so the resulting acceleration is nearly zero. This means, s corresponds to the gap when following other vehicles in steadily flowing traffic. In addition, s increases dynamically when approaching slower vehicles and decreases when the front vehicle is faster. As a consequence, the imposed deceleration increases with The IDM model give the acceleration of a car by this equation: dy dt 7 where (2) The acceleration (eqn 1) is divided into a "desired" acceleration of a car on a free road ( al1-(/v)delta) and braking decelerations induced by the distance to the vehicle ahead (-s*/s) 2. The acceleration on a free road goes to zero when approaching the "desired speed" of v0. The constants a, b, T, and (delta) describe driver behavior (see table below). The braking term is based on a comparison between the "desired dynamical distance" s', and the actual gap s to the preceding vehicle. If the actual gap is approximatively equal to s , then the braking deceleration essentially compensates for the free acceleration part, so the resulting acceleration is nearly zero. This means, s corresponds to the gap when following other vehicles in steadily flowing traffic. In addition, s increases dynamically when approaching slower vehicles and decreases when the front vehicle is faster. As a consequence, the imposed deceleration increases with

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!