delete_block
Delete blocks from Simulink system
Syntax
Description
Examples
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↵Low-pass Filter'} {'f14/Controller/Pitch Rate↵Lead Filter' } {'f14/Controller/Stick↵Prefilter' }
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'})
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 = 396.0024
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
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)