replace_block
Replace blocks in Simulink model
Syntax
Description
replaces the blocks replBlks
= replace_block(sys
,current
,new
)current
in the model
sys
with blocks of type new
.
You can use a block from a Simulink® library or from another model as the replacement block.
The replace_block
function prompts you to select the blocks
you want to replace from a list of blocks that match the
current
argument.
Before using the replace_block
function:
Load the model
sys
. For more information on how to load a model, seeload_system
andopen_system
.If the library containing the new block with which you want to replace the current block is not loaded, load the library. For example, to replace the current block with a Message Triggered Subsystem block, load the Simulink library by entering this command in the MATLAB® Command Window:
load_system('simulink.slx');
Tip
Save the model before replacing blocks.
replaces
the blocks that match the block parameters specified by the replBlks
= replace_block(sys
,Name,Value
,new
)Name,Value
pair
arguments. You can also use find_system
Name,Value
pairs
to qualify the search for blocks to replace.
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
With the replace_block
function, you can
use block parameter and value pairs. For a list of all the block parameters,
see Common Block Properties and Programmatically Specify Block Parameters and Properties.
To specify additional information about the search for blocks
to replace, you use find_system
Name,Value
pairs
before the block parameters. For example, you can use 'CaseSensitive','off'
to
make the search for blocks case insensitive or 'FollowLinks','on'
to
follow links into library links. See find_system
for
that list of Name,Value
pairs.
Examples
Input Arguments
Output Arguments
Version History
Introduced before R2006a