Main Content

delete_block

R2026b

Description

delete_block(blockArg) deletes the specified blocks. The model, library, or subsystem stored in its own file containing the blocks must be loaded.

example

Examples

collapse all

Suppose you have a loaded model named myModel. The model contains a Subsystem block named mySubsystem. The subsystem contains two Integrator blocks named myBlock1 and myBlock2.

Delete the integrator blocks.

delete_block("myModel/mySubsystem/"+["myBlock1","myBlock2"]);

Suppose you have a loaded model named myModel. Delete all blocks in the model containing the keyword filter.

Get the handle of the model.

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

Get the handles of all blocks in the model whose names contain the keyword filter. Use the find_system function.

hBlocks = find_system(hModel,Regexp="on",CaseSensitive="off",Type="Block",Name=".*filter.*")

Delete the blocks.

delete_block(hBlocks);

Input Arguments

collapse all

Blocks to delete, specified as handles or block paths. Format the handles as numeric scalars or numeric arrays. Format the paths as strings, string arrays, character vectors, or cell arrays of character vectors.

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

Example: "myModel/myBlock"

Example: ["myModel/myBlock1";"myModel/myBlock2"]

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

Version History

Introduced before R2006a