File Exchange

image thumbnail

Nagel Schreckenberg model implementation

version 1.4 (4.01 KB) by

Simulation of the Nagel Schreckenberg single-lane traffic model, with visualization and plotting.



View License

Simulation the Nagel Schreckenberg single lane model. All standard parameters are implemented:
-braking probability

Also, rendering flag allows user to disable rendering for faster flow-density curve calculations.

Comments and Ratings (5)


nguyen (view profile)


Son (view profile)

Thomas Kelly

Thomas Kelly

Hi Alex,
I've tried your code out in R2011a and it works perfectly. I'm just wondering how I would go about drawing up a time/cell plot from it to show flow over time? (Similar to what you have implemented in your analyze.m file) I can't quite figure out how to do it.

Thank you in advance


sgtdf (view profile)

Hi Alex,
I tried your code in R2011b, the figure shows a only single straight line at flow value of zero, can you please fix it? Or tell me the reason why? Thank you very much for your help.



Updated to support Octave


Fixed calculated of total flow for FD plot


Fixed a problem with vmax=1 showing zero flow.


Fixed problem with vehicle velocity updates.

MATLAB Release
MATLAB 7.11 (R2010b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today