Main Content

delete_line

R2026b

Delete line from Simulink model

Description

delete_line(sys,out,in) deletes the signal line in the specified model or subsystem that connects the specified output port to the specified input port.

example

delete_line(lineHandle) deletes the signal line with the specified handle. This syntax is equivalent to the previous syntax, but getting one line handle requires fewer commands than getting two port handles.

example

delete_line(sys,point) deletes the line that includes the point point.

example

Examples

collapse all

Suppose you have a loaded model named myModel. The model contains a Gain block named myBlock1 and a Scope block named myBlock2 with two input ports. The output port of the Gain block is connected to the bottom input port of the Scope block. Delete the signal line that connects these blocks.

Determine the port path of the output port. The port path is the block name followed by a slash and the port number. Since the Gain block only has one output port, the port number is 1.

out = "myBlock1/1";

Determine the port path of the input port. The Scope block has two ports. If you pause your pointer on the ports, you can see that the port number of the bottom port is 2.

in = "myBlock2/2";

Delete the signal line that connects the two ports.

sys = "myModel";
delete_line(sys,out,in);

Suppose you have a loaded model named myModel. The model contains a Gain block named myBlock1 and a Scope block named myBlock2 with two input ports. The output port of the Gain block is connected to the bottom input port of the Scope block. Delete the signal line that connects these blocks.

Get the handle of the model.

sys = get_param("myModel","Handle");

Get all port handles of the Gain block.

hGain = get_param("myModel/myBlock1","PortHandles");

Get the output port handle of the Gain block.

out = hGain.Outport;

Get all port handles of the Scope block.

hScope = get_param("myModel/myBlock2","PortHandles");

Get the bottom input port handle of the Scope block.

in = hScope.Inport(2);

Delete the signal line that connects the two ports.

add_line(sys,out,in);

Suppose you have a loaded model named myModel that contains a Sine Wave block named myBlock1 that is connected to two blocks: a Gain block named myBlock2 and a Sum block named myBlock3. Delete the branch of the signal line that connects to the Sum block.

In this example, you want to get the handle of a branch of a signal line. You can get the line handle by using the get_param function to query which signal lines connect to a given block. The branch connects to two blocks. If you query the block connected to the branch at the output port, the get_param function returns the handle of the entire signal line, including all branches. If you query the block connected to the branch at the input port, the function returns the handle of the branch. In this example, you want to get the line handle of a branch, so you want to query the block connected to the branch at the input port, which is the Sum block.

Get the handle of the block you want to query.

hBlock = getSimulinkBlockHandle("myModel/myBlock3");

Get the handles of all signal lines that connect to the Sum block.

hAll = get_param(hBlock,"LineHandles");

Get the handle of the signal line that connects to the first input port of the Sum block.

hInport1 = hAll.Inport(1);

Delete the branch.

delete_line(hInport1);

Suppose you have a loaded model named myModel that contains a Constant block named myBlock1 that is connected to a Gain block named myBlock2. Delete the signal line that connects these blocks.

Get the port locations of the output port on the Constant block.

portConnConst = get_param("myModel/myBlock1","PortConnectivity");
portPosConst = portConnConst.Position;

Delete the signal line that connects the two ports using the port location of the output port.

delete_line("myModel",portPosConst);

Input Arguments

collapse all

Model or subsystem containing the signal line you want to delete. Specify the model as a name, and the subsystem as the block path of the corresponding Subsystem block. Format a handle as a numeric scalar. Format a name or path as a string or character vector.

Example: "myModel"

Example: "myModel/mySubsystem"

Data Types: string | character vector

Block output port connected to the signal line you want to delete, specified as one of these values:

  • Port handle or array of port handles

    Use "PortHandles" with get_param to get the handles.

  • Port path or array of port paths

    The port path is the name of the block to which the port attaches followed by a slash and the port number or name, for example, "myBlock/1". For conditionally executed subsystem blocks and the Integrator block, use port names. For more information, see Get Handles and Paths.

  • An array of either of these port designators.

Format port handles as numeric scalars or numeric arrays. Format port paths as strings, character vectors, or cell arrays of character vectors.

For information about getting handles and paths, see Get Handles and Paths.

Example: h.Outport(1)

Example: "myBlock/1"

Example: {'myBlock1/1','myBlock2/1'}

Tips

Data Types: double | array of doubles | string | character vector | cell array of character vectors

Block input port connected to the signal line you want to delete, specified as one of these values:

  • Port handle or array of port handles

    Use "PortHandles" with get_param to get the handles.

  • Port path or array of port paths

    The port path is the name of the block to which the port attaches followed by a slash and the port number or name, for example, "myBlock/1". For conditionally executed subsystem blocks and the Integrator block, use port names. For more information, see Get Handles and Paths.

  • An array of either of these port designators.

Format port handles as numeric scalars or numeric arrays. Format port paths as strings, character vectors, or cell arrays of character vectors.

For information about getting handles and paths, see Get Handles and Paths.

Example: h.Outport(1)

Example: "myBlock/1"

Example: {'myBlock1/1','myBlock2/1'}

Tips

Data Types: double | array of doubles | string | character vector | cell array of character vectors

Point that falls on the signal line you want to delete, specified as a 1-by-2 matrix.

Example: [150 200]

Handle of the signal line you want to delete. You can get the line handle by using get_param with the LineHandles option or by assigning the line to a handle when you create it programmatically.

For information about getting handles, see Get Handles and Paths.

Data Types: double

Version History

Introduced before R2006a