Main Content

Simulink.BlockDiagram.refreshBlocks

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

Since R2023a

Description

example

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

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.

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

Examples

collapse all

You can programmatically refresh all Model blocks in a model with the Simulink.BlockDiagram.refreshBlocks function.

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.

To support a bulk refresh of the Model blocks, set the Port and parameter mismatch configuration parameter to warning or none.

set_param('RefreshModelBlockModel',...
    'ModelReferenceIOMismatchMessage','none')

Then, refresh the Model blocks.

Simulink.BlockDiagram.refreshBlocks('RefreshModelBlockModel');

model-block-refresh1.png

Each Model block updates to display two input and output ports, matching the number of input and output 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 even when the Model block version mismatch or Port and parameter mismatch configuration parameter is set to error, 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