Main Content

Simulink.ModelReference.refresh

R2026b

Refresh Model block to reflect changes to referenced model

Description

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

When you modify a referenced model and the parent model is loaded but not open, this function lets you refresh a Model block 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 with two Model blocks that each have one input port. 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)

Refresh one of the Model blocks.

Simulink.ModelReference.refresh("mymodel/Model1");

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

Model BlockReferenced Model Input PortsModel Block Input Ports
mymodel/Model133
mymodel/Model231 (outdated)

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