Simulink.ModelReference.refresh

Update Model blocks to reflect changes to referenced models

Description

example

Simulink.ModelReference.refresh(modelBlock) updates the specified Model block to reflect changes to the referenced model.

Examples

collapse all

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

Load the example model, which contains two Model blocks that are out of date with the model they reference. The number of input and output ports in the referenced model has increased from one to two.

load_system('RefreshModelBlockModel');
Warning: Ports and parameters of Model block 'RefreshModelBlockModel/Model1' do not reflect changes in referenced model 'RefreshModelBlockMdlRef'. Revert the changes to the referenced model.
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'. Revert the changes to the referenced model.
Warning: Number of input ports must match between Model block 'RefreshModelBlockModel/Model' (1) and referenced model 'RefreshModelBlockMdlRef' (2).

Refresh one of the Model blocks.

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

The number of ports on the refreshed Model block now matches the number of ports for the referenced model.

To see that the refreshed Model block displays all ports in the referenced model, while the other Model block does not, open the parent model.

open_system('RefreshModelBlockModel');

Input Arguments

collapse all

Model block to refresh, specified as a character vector or a handle.

Example: 'RefreshModelBlockModel/Model'

Data Types: char | string | double

Introduced in R2020a