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_controllers(mycd, cfgf)
function save_controllers(mycd, cfgf)
% SAVE_CONTROLLERS - saves the controller data in the 'celldata' variable
%                    and contents of the configuration file used by 'ctmsim'
%                    to the same configuration file.
%
% Call:
%       save_controllers(mycd)
%       save_controllers(mycd, cfgf)
%
% Parameters:
%             mycd  - array of freeway cell data structures;
%             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_CONTROLLERS: cell data sizes do not match.');
end

for i = 1:N
  celldata(i).ORmlcontroller = mycd(i).ORmlcontroller;
  celldata(i).ORqcontroller  = mycd(i).ORqcontroller;
end

configFile = cfgf;

clear M N i mycd cfgf;

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

return;

Contact us at files@mathworks.com