replace_block
R2026bReplace blocks in Simulink model
Syntax
Description
replaces the specified current blocks in the specified model with new blocks of the
specified type. The replacement block can be a block from a Simulink® library or from another model.replBlks = replace_block(sys,current,new)
Before using the replace_block function:
Load the model
sys. For more information on how to load a model, seeload_systemandopen_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");
This syntax prompts you to select the blocks you want to replace from a list of
blocks that match the current argument.
specifies additional options using one or more replBlks = replace_block(sys,Name=Value,new)Name=Value pair
arguments.
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 the
sys argument.
To replace only blocks that have specific block parameter values, use the
replace_block function with block parameter and value
pairs. For a list of all the block parameters, see Common Block Properties and Programmatically Specify Block Parameters and Properties.
For example,
replace_block("myModel","Amplitude","2","Sin","noprompt")
replaces all blocks in a model named myModel that have an
amplitude of 2 with Sine Wave blocks.
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.
Examples
Input Arguments
Output Arguments
Version History
Introduced before R2006a
