Main Content

delete_line

Delete line from Simulink model

Description

example

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

example

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

example

delete_line(lineHandle) deletes the line using the line handle.

Examples

collapse all

For the model vdp, remove the line connecting the Product block with the Gain block.

load_system('vdp');
delete_line('vdp','Product/1','Mu/1');

For the model vdp, remove a line using the line handle. You can get the line handle using different techniques.

load_system('vdp');
h = get_param('vdp/Mu','LineHandles');
delete_line(h.Outport(1));

Get a line handle when you create the line. Delete the line using that handle.

a = add_line('vdp','Mu/1','Sum/2');
delete_line(a)

You can use a point on the line to delete the whole line.

Find the port coordinates for the block Mu in the model vdp.

open_system('vdp');
mu = get_param('vdp/Mu','PortConnectivity');
mu.Position
ans = 1×2

   190   150

ans = 1×2

   225   150

The line that connects the Mu block to the Sum block starts at the output port, which is at (225,150). You can use any point to the right of that point along the same x-axis to delete the line.

delete_line('vdp',[230,150]);

Use delete_line with branched lines to remove the segment for any connection.

Open the model vdp.

open_system('vdp');

Delete the signal line segment that connects the x1 block to the Out1 block.

delete_line('vdp','x1/1','Out1/1')

A section of the van der Pol Equation model. The signal line segment that connects the Integrator block named x1 to the Outport block named Out1 is deleted.

Delete the signal line segment that connects the x2 block to the Mux block.

delete_line('vdp','x2/1','Mux/2')

A section of the van der Pol Equation model. The signal line segment that connects the Integrator block named x2 to the Mux block is deleted.

Delete the line segment that connects the x2 block to the Product block.

delete_line('vdp','x2/1','Product/2')

A section of the van der Pol Equation model. The signal line segment that connects the Integrator block named x2 to the Product block is deleted.

Input Arguments

collapse all

Model or subsystem to delete the line from, specified as a character vector.

Example: 'vdp' , 'f14/Controller'

Block output port to delete line from, specified as either:

  • The block name, a slash, and the port name or number. Most block ports are numbered from top to bottom or from left to right. For a state port, use the port name State instead of a port number.

  • The port handle that you want to delete the line from.

Use 'PortHandles' with get_param to get the handles.

Example: 'Mu/1', 'Subsystem/2'

Block input port to delete line from, specified as either:

  • The block name, a slash, and the port name or number. The port name on:

    • An enabled subsystem is Enable.

    • A triggered subsystem is Trigger.

    • If Action and Switch Case Action subsystems is Action.

  • The port handle that you want to delete the line from.

Use 'PortHandles' with get_param to get handles.

Example: 'Mu/1', 'Subsystem/2'

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

Example: [150 200]

Handle of the 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.

Version History

Introduced before R2006a