% Modeling and Simulating Social Systems with MATLAB % http://www.soms.ethz.ch/matlab % Authors: % - Stefano Balietti and Karsten Donnay, 2012 % - Tobias Kuhn, 2014 function [density, flow] = simulate_cars_video(moveProb, inFlow) % This function is simulating cars on a highway % INPUT: % moveProb: the probability for a car to move forwards, 0..1 % inFlowProb: The inflow volume to the road, 0..1 % OUTPUT: % density: the average vehicle density, 0..1 % flow: the average flow of cars, 0..1 % set parameter values N=40; % road length nIter=200; % number of iterations % define road (1=car, 0=no car) x = rand(1,N)