Main Content

Simulink.ModelReference.refresh

Force update to Model block to reflect changes to referenced model

Description

Simulink.ModelReference.refresh(mdlblk) updates the Model block specified by mdlblk to reflect changes to the referenced model.

example

Examples

collapse all

Create a model hierarchy with a parent model that references the same model twice.

new_system("top")
new_system("ref")
add_block("simulink/Ports & Subsystems/Model","top/Model1",ModelName="ref")
add_block("simulink/Ports & Subsystems/Model","top/Model2",ModelName="ref")

Add an input and output port to the referenced model.

add_block("simulink/Ports & Subsystems/In1","ref/In1")
add_block("simulink/Ports & Subsystems/Out1","ref/Out1")

Get the number of ports on the Model blocks.

get_param("top/Model1","Ports")
ans = 1×10

     0     0     0     0     0     0     0     0     0     0

get_param("top/Model2","Ports")
ans = 1×10

     0     0     0     0     0     0     0     0     0     0

The Model blocks do not reflect the new ports in the referenced model.

Refresh one of the Model blocks.

Simulink.ModelReference.refresh("top/Model1");
get_param("top/Model1","Ports")
ans = 1×10

     1     1     0     0     0     0     0     0     0     0

get_param("top/Model2","Ports")
ans = 1×10

     0     0     0     0     0     0     0     0     0     0

The number of ports on the refreshed Model block now matches the number of ports in the referenced model. The other Model block remains unchanged.

Input Arguments

collapse all

Name or handle of Model block, specified as a character vector, string scalar, or numeric scalar.

Example: Simulink.ModelReference.refresh('mymodel/Model')

Example: Simulink.BlockDiagram.refreshBlocks(h), where h is a Model block handle

Tips

Do not try to manually specify the number of a handle, for example, 5.007, because you usually need to specify more digits than MATLAB® displays. Assign the handle to a variable and use that variable name.

Data Types: char | string | double

Tips

To refresh all variants, linked blocks, and Model blocks in a model, use the Simulink.BlockDiagram.refreshBlocks function.

Alternative Functionality

Select a Model block. In the Simulink® Toolstrip, on the Model Block tab, click Refresh .

Version History

Introduced in R2020a