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

plotbar(X, Y, C)
function plotbar(X, Y, C)
% PLOTBAR - plots bar chart, slightly different from 'bar()' function - here
%           one can specify width of individual bars.
%
% Call:   plotbar(X, Y, C)
%
% Parameters:
%             X - specifies the devision of the X axis into segments;
%             Y - contains values (heights) of corresponding bars;
%             C - color (can be veertical array or single value).
%
% Returns:   none
%
% Last modified:   07/30/2006.

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

m = size(X, 2);
n = size(Y, 2);
if m  ~=  (n + 1)
  error('PLOTBAR: sizes of X and Y do not match.');
end

k = size(C, 1);
if (k ~= n) & (k ~= 1)
  error('PLOTBAR: sizes of X and C do not match.');
end

ih = ishold;

for i = 1:n
  xx = [X(i) X(i) X(i+1) X(i+1)];
  yy = [0 Y(i) Y(i) 0];
  if k == 1
    fill(xx, yy, C);
  else
    fill(xx, yy, C(i, :));
  end
  hold on;
end

if ih == 0
  hold off;
end

return;

Contact us at files@mathworks.com