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_fd(mycd, cfgf)
function save_fd(mycd, cfgf)
% SAVE_FD - saves the fundamental diagram data in the 'celldata' variable
%           and contents of the configuration file used by 'ctmsim'
%           to the same configuration file.
%
% Call:
%       save_fd(mycd)
%       save_fd(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_FD: cell data sizes do not match.');
end

for i = 1:N
  celldata(i).FDfmax    = mycd(i).FDfmax;
  celldata(i).FDrhocrit = mycd(i).FDrhocrit;
  celldata(i).FDrhojam  = mycd(i).FDrhojam;
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