Have you ever needed to draw a bunch of rectangles on a figure? Did your code look like this:
rectangle('Position',blah blah blah...);
This code can become quite slow when the number of rectangles increases significantly. I wrote the RECTANGLES function to solve this problem by plotting multiple rectangles as a single patch.
The only required input is an Mx4 array of rectangle vectors [x,y,w,h] corresponding to M rectangles.
See the function header for additional details and a list of optional parameters. Run the demo script if you want to view sample results fast without writing any code yourself.
Matthew Eicholtz (2024). rectangles (https://www.mathworks.com/matlabcentral/fileexchange/59243-rectangles), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!