| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
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 'src' block to a new 'dest' block. Specify the full path name for 'src' and 'dest', unless the source block is a built-in, nonmasked Simulink block. Instead, you can specify 'src' to be 'built-in/blocktype', where blocktype is the value of the BlockType parameter of the source block. If the 'src' block is a Subsystem block, then add_block copies all the blocks in the subsystem. The parameter values of the new block are identical to the parameter values of the source block.
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.
A built-in block is a block that is available in Simulink block libraries.
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. Open the destination model (f14); you do not need to open the simulink/Sinks library.
open_system('f14');
add_block('simulink/Sinks/Scope', 'f14/Contoller/Scope')
Create a subsystem named Controller2 in the f14 system.
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.
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
![]() | Functions — Alphabetical List | add_exec_event_listener | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |