| Simulink® | ![]() |
add_block('src', 'dest')
add_block('src', 'dest', 'param1', value1, ...)
add_block('src', 'dest', 'MakeNameUnique', 'on', 'param1',
value1,...)
add_block('src_inport', 'dest_inport', 'copyoption', 'duplicate',
'param1', value1,...)
add_block('src', 'dest') copies the block with the full pathname 'src' to a new block with the full pathname 'dest'. The block parameters of the new block are identical to those of the original. You can use 'built-in/blocktype' as a source block path for Simulink built-in blocks (blocks available in Simulink block libraries that are not masked blocks), where blocktype is the built-in block's type, i.e., the value of its BlockType parameter (see Common Block Parameters).
add_block('src', 'dest', 'param1', value1, ...) creates a copy as above, in which the named parameters have the specified values. Any additional arguments must occur in parameter/value pairs.
add_block('src', 'dest', 'MakeNameUnique', 'on', 'parameter1', value1,...) creates a copy of src. If a block having the full pathname 'dest' already exists, the command creates a unique name for the new block based on 'dest'.
add_block('src_inport', 'dest_inport', 'copyoption', 'duplicate', 'param1', value1,...) applies only to Inport blocks. It creates a copy with the same port number as the 'src_inport' block.
Before you add a block, you need to first open the library that contains the block with the load_system (library opens invisibly) or open_system (library opens visibly) command.
This command copies the Scope block from the Sinks subsystem of the simulink system to a block named Scope1 in the timing subsystem of the engine system.
add_block('simulink/Sinks/Scope', 'engine/timing/Scope1')
This command creates a new subsystem named controller in the F14 system.
add_block('built-in/SubSystem', 'F14/controller')
This command copies the built-in Gain block to a block named Volume in the mymodel system and assigns the Gain parameter a value of 4.
add_block('built-in/Gain', 'mymodel/Volume', 'Gain', '4')
The following command
block = add_block('vdp/Mu', 'vdp/Mu', 'MakeNameUnique', 'on')
copies the block named Mu in vdp and create a copy. Since Mu already exists, the command names the new block Mu1.
![]() | Functions — Alphabetical List | add_exec_event_listener | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |