| Contents | Index |
add_block('src', 'dest')
block = add_block('src', 'dest')
add_block('src', 'dest', 'param1', value1,
...)
add_block('src', 'dest',
'MakeNameUnique', 'on')
add_block('src_inport', 'dest_inport',
'CopyOption', 'duplicate')
add_block('src', 'dest') copies the block with the full path name that you specify with 'src' to a new block with a full path name that you specify with 'dest'. The block parameters of the new block are identical to those of the original. If the 'src' block is a Subsystem block, then add_block copies all the blocks in the subsystem.
block = add_block('src', 'dest') returns the handle of the newly created block.
add_block('src', 'dest', 'param1', value1, ...) creates a copy of the 'src' block, with the named parameters having the specified values. Additional arguments must occur in parameter/value pairs.
add_block('src', 'dest', 'MakeNameUnique', 'on') creates a unique name for the new block, based on the name of the 'dest' block. The add_block function creates a unique name only if the 'dest' block name exists in the model into which you add the new block. By default, MakeNameUnique is off.
add_block('src_inport', 'dest_inport', 'CopyOption', 'duplicate') applies only to Inport blocks. It creates a copy with the same port number as the 'src_inport' block.
Before you add a block from a source model, open the source model. For example, use load_system (model opens invisibly) or open_system (model opens visibly). Also open the destination model if it is different from the source model.
Calling add_block triggers the CopyFnc and PreCopyFcn block callback functions.
You can use 'built-in/blocktype' as a source block path name for Simulink built-in blocks, where blocktype is the built-in block type (that is, the value of its BlockType parameter (see Common Block Parameters). However, using 'built-in/blocktype' causes some default parameter values of some blocks to be different from the defaults that you get if you added those blocks interactively using Simulink.
Copy the Scope block from the Sinks subsystem of the simulink system to a block named Scope in the Controller subsystem of the f14 system.
simulink;
open_system('f14');
add_block('simulink/Sinks/Scope', 'f14/Controller/Scope')
Create a subsystem named Controller2 in the f14 system. You do not have to open the Library Browser.
open_system('f14');
add_block('built-in/SubSystem', 'f14/Controller2')
Copy the built-in Gain block to a block named Speed in the f14 system and assign the Gain parameter a value of 4. You do not have to open the Library Browser.
open_system('f14');
add_block('built-in/Gain', 'F14/Speed', 'Gain', '4')
Copy the block named Mu in vdp and create a copy. Because the model already contains a Mu block, the command names the new block Mu1. Open the vdp model, which is both the source and destination model, and get the handle of the added block.
open_system('vdp');
block = add_block('vdp/Mu', 'vdp/Mu', 'MakeNameUnique', 'on')
delete_block | replace_block | set_param

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 |