This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Add line to Simulink model


h = add_line('sys','oport','iport')
h = add_line('sys','oport','iport', 'autorouting','on')
h = add_line('sys',points)


add_line adds a line to the specified model and returns a handle to the new line. You can define the line in two ways:

  • Specify the location of the points that define the line segments

  • Use block port handles or IDs to specify the ports to connect

add_line(system, points) adds a segmented routed line to a system. Each row of the points array specifies the (x,y) coordinates of a point on a line segment. The origin is the top-left corner of the window. The signal connection extends from the point defined in the first row of the array to the point defined in the last row. If the start point of the new line is within five points of the output of an existing block or line, a connection is made. Likewise, if the end point of the line is within five points of an existing input, a connection is made.

add_line('sys', 'oport', 'iport') adds a straight line to a system from the specified block output port 'oport' to the specified block input port 'iport'.

add_line('sys','oport','iport', 'autorouting','on') works like add_line('sys','oport','iport') except that it routes the line around intervening blocks. The default value for autorouting is 'off'.

You can specify 'oport' and 'iport' of a block when using add_line with:

  • Block port names and IDs

  • Block port handles

When using block port names and IDs, 'oport' and 'iport' consist of a block name and a port identifier in the form 'block name/port number'. For example:


Most block ports are numbered from top to bottom or from left to right. Identification of Enable, Trigger, State, and Action ports is done by name instead of number. For example:

  • 'subsystem_name/Enable'

  • 'subsystem_name/Trigger'

  • 'Integrator/State'

  • if_action_subsystem_name/Ifaction'

When using block port handles, 'oport' and 'iport' correspond to block output and input port handles. Use the get_param function to get the block port handles. For example:

SubsysPortHandles = get_param('mymodel/Subsystem1','PortHandles')
ScopePortHandles = get_param('mymodel/Scope1','PortHandles')

Introduced before R2006a

Was this topic helpful?