View License

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

» Watch video

Highlights from

4.7 | 6 ratings Rate this file 5 Downloads (last 30 days) File Size: 18.1 KB File ID: #31576 Version:
image thumbnail



Mike Anthony (view profile)


25 May 2011 (Updated )

Automatically resizes the number of ports on a block for automatic connection.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

In many cases, Simulink® users have multiple blocks that they wish to connect to a block, particularly mux, demux, and bus creator blocks. The current practice is to drag one of these blocks from the Simulink library browser into the model. The mux block, for example, by default has 2 input ports. If you have 4 blocks that you wish to connect, you must open the mask of the mux block and set the number of inputs to 4. This will then create 4 input ports on the mux block. The user can then select the 4 blocks he/she wishes to connect to the mux block, hold CTRL, and select the mux block to automatically connect all of the blocks.
This function eliminates the manual step of opening the mask and setting the number of desired inports/outports and does that automatically based on the number of blocks the user selected to try to connect.

Open the included Simulink model AutoSizeOnConnect.mdl and follow the instructions therein to see an example of how to use this function.

This functional is especially useful when used in conjunction with AutoSize, which is included in this submission but can also be downloaded separately (see Acknowledgements below).


Auto Size inspired this file.

Required Products Simulink
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
15 Jul 2013 Lorenz Padberg

Very nice,
Something to add: Bus Creator.
When I select a certain Bus Object in the bus creator dialog I d whish it would name the signals according to the Bus Object... now I have to enter them manually..

27 Jun 2013 Stephane Dauvillier

Thumbs up!

27 Jun 2013 Selmane Sekkai

27 Jun 2013 Jean-Baptiste Lanfrey

Congrats! it's awesome.

29 Mar 2013 Mike Anthony

Mike Anthony (view profile)

Hi huang,

I have not been able to replicate the issue that you describe. Are you definitely using the latest update of the files?

If you have a sample model that you could send I'd be more than happy to figure out what's going on. Thanks!

Comment only
13 Mar 2013 huang

huang (view profile)

Hi, Mike Anthony.
I got a bug, which i think.
when i dislink a block to the buscreator,which i used the tool to connected, and relink it to the block normally, something unrespected happend, the buscreator resized.
hope it useful to you,and fixed the hole.

Comment only
13 Mar 2013 huang

huang (view profile)

04 Feb 2013 Ryan G

Ryan G (view profile)

27 May 2011 1.1

Updated references, updated screenshot, and fixed minor typos in the files.

03 Jun 2011 1.2

added acknowledgement reference.

16 Jun 2011 1.3

Updated AutoSizeOnConnect.m to handle Multiple Input blocks with 'NumInputs' property (like the VectorConcatenate block)

17 Dec 2012 1.5

Updates to handle blocks with multiple inports/outports.

04 Feb 2013 1.6

Update to work with Scope blocks!

08 Feb 2013 1.7

Fixes error if no blocks are selected.

26 Jun 2013 1.8

Update that I think fixes the bug that huang reported. This fix also reduces the number of function calls and should improve performance as well.

01 Sep 2016

Updated license

Contact us