Simulink Reference | ![]() ![]() |
Replace blocks in a Simulink model.
Syntax
replace_block('sys', 'blk1', 'blk2', 'noprompt') replace_block('sys', 'Parameter', 'value', 'blk', ...)
Description
replace_block('sys', 'blk1', 'blk2')
replaces all blocks in 'sys'
having the block or mask type 'blk1'
with 'blk2'
. If 'blk2'
is a Simulink built-in block, only the block name is necessary. If 'blk'
is in another system, its full block pathname is required. If 'noprompt'
is omitted, Simulink displays a dialog box that asks you to select matching blocks before making the replacement. Specifying the 'noprompt'
argument suppresses the dialog box from being displayed. If a return variable is specified, the paths of the replaced blocks are stored in that variable.
replace_block('sys', 'Parameter', 'value', ..., 'blk')
replaces all blocks in 'sys'
having the specified values for the specified parameters with 'blk'
. You can specify any number of parameter name/value pairs.
Note Because it may be difficult to undo the changes this command makes, it is a good idea to save your system first. |
Example
This command replaces all Gain blocks in the f14
system with Integrator blocks and stores the paths of the replaced blocks in RepNames
. Simulink lists the matching blocks in a dialog box before making the replacement.
This command replaces all blocks in the Unlocked
subsystem in the clutch
system having a Gain
of 'bv'
with the Integrator block. Simulink displays a dialog box listing the matching blocks before making the replacement.
This command replaces the Gain blocks in the f14
system with Integrator blocks but does not display the dialog box.
See Also
![]() | open_system | save_system | ![]() |