delete_block
Delete blocks from Simulink system
Syntax
Description
Examples
Delete Blocks Using Full Path Name
You can programmatically delete a block from the library using the delete_block
function with one of these input arguments:
Full block path including block name, for example,
'myModel/mySubsystem/myblock'
Block handle
This example shows how to programmatically delete blocks using the full block path.
Delete One Block
Delete the pitch rate filter from the f14
model.
Open the example. Then, load or open the model.
open_system('f14')
Suppose you do not know the exact name of the block needed to complete this task or the location of the block in the model.
Get the full block paths of all blocks in the f14
model using the find_system
function.
Paths=find_system('f14','Type','Block');
Narrow the results down to the paths that contain the word filter
or Filter
.
FilterPaths=Paths(contains(Paths,{sprintf('Filter'),sprintf('filter')})); disp(FilterPaths)
{'f14/Controller/Alpha-sensor...'} {'f14/Controller/Pitch Rate...' } {'f14/Controller/Stick...' }
When you specify a multiline full block path, specify the transition to a new line with a space. The full block path of the pitch rate filter is 'f14/Controller/Pitch Rate Lead Filter'
.
Delete the block using the full block path.
delete_block('f14/Controller/Pitch Rate Lead Filter')
To verify that the block is deleted, open the Controller
subsystem.
open_system('f14/Controller')
Delete Multiple Blocks
Delete the other two filter blocks.
delete_block({'f14/Controller/Alpha-sensor Low-pass Filter','f14/Controller/Stick Prefilter'})
Delete Blocks Using Block Handle
You can programmatically delete a block from the library using the delete_block
function with one of these input arguments:
Full block path including block name, for example,
'myModel/mySubsystem/myblock'
Block handle
This example shows how to programmatically delete blocks using the block handle.
Delete One Block
Delete the pitch rate filter from the f14
model.
Open the example. Then, load or open the model.
open_system('f14')
Get the handle of the Transfer Function block named Pitch Rate Lead Filter
in the Controller
subsystem.
h=getSimulinkBlockHandle('f14/Controller/Pitch Rate Lead Filter')
h = 397.0020
Delete the block using the handle.
delete_block(h)
To verify that the block is deleted, open the Controller
subsystem.
open_system('f14/Controller')
Delete Multiple Blocks
Get the handles of the Transfer Function blocks named Alpha-sensor Low-pass Filter
and Stick Prefilter
in the Controller
subsystem.
h1=getSimulinkBlockHandle('f14/Controller/Alpha-sensor Low-pass Filter'); h2=getSimulinkBlockHandle('f14/Controller/Stick Prefilter');
Delete the other two filter blocks.
delete_block([h1, h2])
Input Arguments
blockArg
— Blocks to delete
full path name | handle | vector of handles | 1-D cell array or string array of handles or block path names
Blocks to delete, specified as the full block path name, a handle, a vector of handles, or a 1-D cell array or string array of handles or block path names.
Example: 'vdp/Mu'
Example: [handle1
handle2]
Example: {'vdp/Mu'
'vdp/Out1' 'vdp/Out2'}
Example: "vdp/Out"+(1:2)
Version History
Introduced before R2006a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)