Contenido principal

Simulink.BlockDiagram.refreshBlocks

Update variants, linked blocks, and model references to reflect changes

Since R2023a

Description

Simulink.BlockDiagram.refreshBlocks(model) refreshes all variants, linked blocks, and Model blocks in the specified model.

To refresh blocks in referenced models, call this function for each 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 the Model blocks.

Simulink.BlockDiagram.refreshBlocks("top");
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

     1     1     0     0     0     0     0     0     0     0

The number of ports on the refreshed Model blocks now match the number of ports in the referenced model.

Input Arguments

collapse all

Name or handle of loaded model, specified as a character vector, string scalar, or numeric scalar.

Example: Simulink.BlockDiagram.refreshBlocks("mymodel")

Example: Simulink.BlockDiagram.refreshBlocks(h), where h is a model 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 a specified Model block, use the Simulink.ModelReference.refresh function.

Alternative Functionality

In the Simulink® Toolstrip, on the Modeling tab, click the Update Model button arrow. Then, select Refresh Blocks.

Version History

Introduced in R2023a