Skip to Main Content Skip to Search
Product Documentation

replace_block - Replace blocks in Simulink model

Syntax

replace_block('sys', 'old_blk', 'new_blk')
replace_block('sys', 'parameter', 'value', ..., 'blk')

Description

replace_block('sys', 'old_blk', 'new_blk') replaces all blocks in sys having the block or mask type old_blk with new_blk.

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. You can also specify find_system parameter/value pairs followed by any number of block parameter/value pairs. For example, to replace blocks inside links, specify 'FollowLinks', 'on' to follow links into library blocks. For information on block parameters, see Model and Block Parameters

Examples

This command replaces all Gain blocks in the f14 system with Integrator blocks and stores the paths of the replaced blocks in RepNames. Simulink software lists the matching blocks in a dialog box before making the replacement.

RepNames = replace_block('f14','Gain','Integrator')

This command replaces all blocks in the Unlocked subsystem in the clutch system having a Gain of 'bv' with the Integrator block. Simulink software displays a dialog box listing the matching blocks before making the replacement.

replace_block('clutch/Unlocked','Gain','bv','Integrator')

This command replaces the Gain blocks in the f14 system with Integrator blocks but does not display the dialog box.

replace_block('f14','Gain','Integrator','noprompt')

This command replaces the Small_Wheel subsystem in the wheel_analysis model with the Large_Wheel subsystem from the wheels library.

replace_block('wheel_analysis','Name','Small_Wheel','wheels/Large_Wheel')

This command from the mask initialization of a linked block replaces blocks inside itself:

replace_block(gcb, 'FollowLinks', 'on', 'BlockType', 'Gain', 'Integrator', 'noprompt')

See Also

find_system | set_param

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS