File Exchange

image thumbnail


version (58.6 KB) by Joerg Buchholz
Block diagram Optimization Tool


Updated 24 Feb 2014

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

BOT optimizes the layout of the current Simulink block diagram.
Blocks and lines are resized and moved until their vertices satisfy a 5 pixel grid.

You can define safety zones around blocks and line; The program then moves blocks and lines, until their safety zones do not overlap. Think of blocks and lines as magnets repelling each other.

Lines can be rerouted and intersecting lines can be untangled.

Finally, the program tries to compact the diagram by moving the blocks closer to each other. Think of lines as contracting rubber bands.

Cite As

Joerg Buchholz (2021). BOT (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (26)

Joerg Buchholz

@Farzaneh: I don't have access to SimBiology but I do not think you can use bot for SimBiology models.

Farzaneh Maleki

How can I use this tool for Simbiology models?

Miran Dabare

Joerg Buchholz

@Angelika (@d ef): I get the impression that you opened bot.fig instead of executing bot.m. Could that be the reason ...?

Angelika Döbrössy

This tool sounds quire amazing!!!
But I get the same error as "d ef" documented o 30.Aug.2017
I tried it with the demo_model "bot_demo" and with a simple model, just conecting an input to an output.
With the Releases R2017b and R2018b.
Is there any solution, to make the "Bot" run?

Error message in ComandWindow:
Struct contents reference from a non-struct array object.
Error in bot>pushbutton_start_Callback (line 236)
set (handles.pushbutton_start, 'Enable', 'off')
Error in gui_mainfcn (line 95)
Error in bot (line 35)
gui_mainfcn(gui_State, varargin{:});
Error in>@(hObject,eventdata)bot('pushbutton_start_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

Bhaskar R

Its really amazing!!!
But taking time to arrange model

Joerg Buchholz

@d ef: I have had many problems with windows after reawakening from sleep mode in the past. Sometimes the internet connection was lost, sometimes programs awoke in a damaged state. And yes indeed, I could very well imagine Matlab having some trouble reestablishing internal communication lines and memory space after a wake-up. My poor man's recommendation to solve that problem would simply be to avoid it: Don't bot and respawn. ;-)

d ef

@Joerg Buchholz I'm gonna try it on a few other machines with the same version as I have, as well as R2017a.
In the mean time, are you aware of any issues that may arise when you put a machine in sleepmode while a model is open along with BOT and then later resume the machine and continue with that model and BOT?
Because if my memory serves me right, that was the "tipping point" that caused BOT to stop functioning. Really strange.

Joerg Buchholz

@d ef: It is difficult for me to find a bug I cannot reproduce. Could you try it on a different machine in order to see if your problem is consistent? Does anybody else have that problem?

d ef

@Joerg Buchholz: Well, no. In fact I have succesfully utilized it before on my 2016a version. But now I just can't get it to run anymore.

Joerg Buchholz

@d ef: I just tested it with R2017a without an error. Which version did you use? Is your environment "special" in any way?

d ef

No longer functioning. When attempting to use it on the demo file gives the following list of errors:

Attempt to reference field of non-structure array.

Error in bot>pushbutton_start_Callback (line 236)
set (handles.pushbutton_start, 'Enable', 'off')

Error in gui_mainfcn (line 95)

Error in bot (line 35)
gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)bot('pushbutton_start_Callback',hObject,eventdata,guidata(hObject))

Mustafa Hathiyari

Ahmed ElTahan

Joerg Buchholz

@Shivam Khandelwal: Open a Simulink model, open bot, press Start.

Shivam Khandelwal

How to use it?


James Marriott

Joerg Buchholz

@The Matlab Spot: Unchecking "Forwards" or "Backwards" should do the job.

Joerg Buchholz

BOT is in early pre-beta state.

It cannot handle blocks with in- and outports on more than two sides (enabled subsystems, sums with multiple inputs, ...). Blinkers (oscillations) and Starships (runaway groups of blocks) occur. Text is ignored. Inports are not swapped. The width of blocks is not optimized ...

And most of all, BOT is incredibly slow. Diagrams with more than 10 blocks and 10 lines really put your patience on the test.

Speedwise, BOT should not be an external third party product. It should be implemented as a core functionality of Simulink.

Dear Mathworks: Google can go thousands of miles in a driverless car. You should at least give us an autoroute algorithm without overlapping lines!


Great idea. Needs work. Does not work on enabled subsystems.



The Matlab Spot

one extra just for the animation :)

The Matlab Spot

The Matlab Spot

Very nice! :) well done...

Need to work on the feedback loops. Gets stuck into a recursive loops while adjusting the model with feedback loops

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!