Main Content

Simulink.ModelReference.refresh

Force update to Model block to reflect changes to referenced model

Since R2020a

Description

example

Simulink.ModelReference.refresh(modelBlock) updates the specified Model block, modelBlock, to reflect changes to the referenced model. The block updates even when the Model block version mismatch or Port and parameter mismatch configuration parameter is set to error.

Examples

collapse all

You can programmatically refresh a Model block in a parent model that has the Port and parameter mismatch configuration parameter set to error.

Open the example model, which contains two Model blocks that are out of date with the model they reference.

open_system('RefreshModelBlockModel');
Warning: Ports and parameters of Model block 'RefreshModelBlockModel/Model1' do not reflect changes in referenced model 'RefreshModelBlockMdlRef'.
Warning: Number of input ports must match between Model block 'RefreshModelBlockModel/Model1' (1) and referenced model 'RefreshModelBlockMdlRef' (2).
Warning: Ports and parameters of Model block 'RefreshModelBlockModel/Model' do not reflect changes in referenced model 'RefreshModelBlockMdlRef'.
Warning: Number of input ports must match between Model block 'RefreshModelBlockModel/Model' (1) and referenced model 'RefreshModelBlockMdlRef' (2).

model-block-refresh.png

The top model has the Port and parameter mismatch configuration parameter set to error. The number of input and output ports in the referenced model has increased from one to two, but each Model block displays only one input and output port.

Refresh one of the Model blocks.

Simulink.ModelReference.refresh('RefreshModelBlockModel/Model');

model-block-refresh2.png

The number of ports on the refreshed Model block now matches the number of ports for 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. With this function, the Model blocks update only when the Model block version mismatch and Port and parameter mismatch configuration parameters are set to none or warning. The Model blocks do not update when either configuration parameter is set to error.

Alternative Functionality

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

Version History

Introduced in R2020a