Contenuto principale

Simulink.BlockDiagram.refreshBlocks

R2026b

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

Since R2023a

Description

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

To refresh blocks in referenced models, call this function for each referenced model.

When you modify a referenced model and the parent model is loaded but not open, this function lets you refresh the Model blocks in a model without compiling, simulating, or generating code for the model hierarchy.

example

Examples

collapse all

When you modify a referenced model and the parent model is loaded but not open, the Model blocks do not automatically refresh.

Suppose you have a model hierarchy with four Model blocks that each have one input port. Two of the Model blocks are in the top-level model. The other two are in mid-level models. While the models are loaded but not open, you increase the number of input ports in the referenced models from one to three. The Model blocks do not reflect the new ports in the referenced models.

Model BlockReferenced Model Input PortsModel Block Input Ports
mymodel/Model131 (outdated)
mymodel/Model231 (outdated)
mid1/Model31 (outdated)
mid2/Model31 (outdated)

Refresh the Model blocks in the top model of the model hierarchy.

Simulink.BlockDiagram.refreshBlocks("mymodel");

The number of ports on the Model blocks in the top model now matches the number of ports in the referenced model. The number of ports on the Model blocks in the mid-level models remains unchanged.

Model BlockReferenced Model Input PortsModel Block Input Ports
mymodel/Model133
mymodel/Model233
mid1/Model31 (outdated)
mid2/Model31 (outdated)

Refresh the Model block in the first mid-level model.

Simulink.BlockDiagram.refreshBlocks("mid1");

The number of ports on the Model block in the specified mid-level model now matches the number of ports in the referenced model. The number of ports on the Model block in the other mid-level model remains unchanged.

Model BlockReferenced Model Input PortsModel Block Input Ports
mymodel/Model133
mymodel/Model233
mid1/Model33
mid2/Model31 (outdated)

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