File Exchange

image thumbnail

Bresenham optimized for Matlab

version (1.4 KB) by Aaron Wetzler
An implementation of the classic algorithm with code optimized for Matlab


Updated 15 Jul 2010

View Version History

View License

This code does not use any for loops and takes advantage of Matlabs internally optimized routines to produce a fast, optimized version of Bresenham's line drawing algorithm

Cite As

Aaron Wetzler (2021). Bresenham optimized for Matlab (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

Milena Mori

Lucyanno Frota


Shuvo Sarker

Readability is not so good! But I appreciate your work. Thanks.

William Chamberlain

Missing a couple of terminating ';', but I don't care _because it works_ .

John Doe

Geoffrey Vincent

Excellent, especially because he will work with negative values!

Gerhard Keuck


I believe cumsum(q) is equivalent to round(0:(dy/dx):dy), anyway, I posted some code at: that uses same logic but is about 20% faster.

Sushant Kulkarni


Jordi Palacin


What does this equation mean?


Very efficient, and well made. Code comments messy, and lines not terminated with ;.


Christian Wengert

compact and elegant implementation

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!