Code covered by the BSD License  

Highlights from
CTMSIM - an interactive freeway traffic macrosimulator

image thumbnail
from CTMSIM - an interactive freeway traffic macrosimulator by Alex Kurzhanskiy
Freeway traffic simulation based on Asymmetric Cell Transmission Model

compute_traveltime(speeds, celldata)
function tt = compute_traveltime(speeds, celldata)
% COMPUTE_TRAVELTIME - computes and returns individual travel time (in minutes)
%                      over a freeway section described by array of cells.
%
% Call:   tt = compute_traveltime(speeds, celldata)
%
% Parameters:
%             speeds   - vector of speeds;
%             celldata - array of cell data structures,
%                         whose length must be the same as size of 'speeds';
%
% Returns:   tt - individual travel time over given freeway section.
%
% Last modified:   09/22/2006.

%
% Alex Kurzhanskiy   <akurzhan@eecs.berkeley.edu>
%

M = size(speeds, 1);
N = size(celldata, 2);

if (M ~= N)
  error('COMPUTE_TRAVELTIME: number of speeds does not match number of cells.');
end

tt = 0;

for i = 1:N
  tt = tt  +  60 * (abs(celldata(i).PMend - celldata(i).PMstart) / speeds(i, 1));
end

return;

Contact us at files@mathworks.com