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

set_fr_split_ratios(celldata, betas)
function new_cd = set_fr_split_ratios(celldata, betas)
% SET_FR_SPLIT_RATIOS - set off-ramp split ratio values to the array of freeway 
%                       cell data structures from given vector.
%
% Call:   new_cd = set_fr_split_ratios(celldata, betas)
%
% Parameters:
%             celldata - array of freeway cell data structures;
%             betas    - vector of off-ramp split ratios whose size must be
%                        the same as number of cells.
%
% Returns:   new_cd - updated array of freeway cells.
%
% Last modified:   09/26/2007.

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

N = size(celldata, 2);  % number of cells
M = size(betas, 1);

if M ~= N
  error('SET_FR_SPLIT_RATIOS: size of split ratio vector does not match the number of cells.');
end

new_cd = celldata;

for i = 1:N
  if ~isempty(new_cd(i).FRname) & (betas(i, 1) >= 0) & (betas(i, 1) <= 1)
    new_cd(i).FRbeta = betas(i, 1);
  else
    new_cd(i).FRbeta = 0;
  end
end

return;

Contact us at files@mathworks.com