Main Content

pil_block_replace

Replace block in model with block from another model

Description

pil_block_replace(sourceModelBlock, destinationModelBlock) replaces a block in the destination model with a block from the source model. To preserve the original block from the destination model, in the source model, the function replaces sourceModelBlock with destinationModelBlock.

pil_block_replace(sourceModelBlock, destinationModelBlock, 'isvisible') highlights the replaced block in the destination model.

example

Examples

collapse all

This example shows how to replace a block in a model with a block from another model.

Create a destination model that contains an Outport block, destinationBlock.

new_system('destModel')
open_system('destModel');
add_block('simulink/Sinks/Out1', 'destModel/destinationBlock')

Create a source model that contains a Scope block, sourceBlock.

new_system('srcModel')
open_system('srcModel');
add_block('simulink/Sinks/Scope', 'srcModel/sourceBlock')

Replace the Outport block in the destination model with the Scope block from the source model.

pil_block_replace('srcModel/sourceBlock','destModel/destinationBlock','isvisible')

Input Arguments

collapse all

Full path to the replacement block in the source model.

Example: 'srcModel/sourceBlock'

Full path to the block in the destination model, which the source block replaces.

Example: 'destModel/destinationBlock'

Version History

Introduced in R2006b