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

save_rd(mycd, ifl, ofl, cfgf)
function save_rd(mycd, ifl, ofl, cfgf)
% SAVE_RD - saves the ramp data in the 'celldata' variable
%           and contents of the configuration file used by 'ctmsim'
%           to the same configuration file.
%
% Call:
%       save_rd(mycd)
%       save_rd(mycd, cfgf)
%
% Parameters:
%             mycd  - array of freeway cell data structures;
%             ifl   - main line flow entering the first cell;
%             ofl   - main line flow leaving the last cell;
%             cfgf  - (optional) name of configuration file, whose contents
%                     must be also saved.
%
% Returns:   none.
%
% Last modified:   10/20/2006.

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

if nargin < 2
  cfgf = 'ctm';
end

load(cfgf);

M = size(mycd, 2);
N = size(celldata, 2);

if M ~= N
  error('SAVE_RD: cell data sizes do not match.');
end

for i = 1:N
  celldata(i).ORflow = mycd(i).ORflow;
  celldata(i).FRbeta = mycd(i).FRbeta;
end

configFile = cfgf;
inflow     = ifl;
outflow    = ofl;

clear M N i ifl ofl mycd cfgf;

if str2num(version('-release')) >= 14
  feval(@save, '-v6', configFile);
else
  feval(@save, configFile);
end

return;

Contact us at files@mathworks.com