File Exchange

image thumbnail

Nagel Schreckenberg model implementation

version (4.01 KB) by Alexander Farley
Simulation of the Nagel Schreckenberg single-lane traffic model, with visualization and plotting.


Updated 10 Feb 2015

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.

Cite As

Alexander Farley (2019). Nagel Schreckenberg model implementation (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)



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


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 Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux