Simulink.ModelReference.refresh
Update Model blocks to reflect changes to referenced models
Description
Simulink.ModelReference.refresh(
updates the specified Model block to reflect changes to the referenced
model.modelBlock
)
Examples
Refresh Model Blocks Programmatically
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'.
Warning: Number of input ports must match between Model block 'RefreshModelBlockModel/Model1' (1) and referenced model 'RefreshModelBlockMdlRef' (2). Suggested Actions: • Refresh the Model block 'RefreshModelBlockModel/Model1'. - Fix • Revert the changes to the referenced model.
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). Suggested Actions: • Refresh the Model block 'RefreshModelBlockModel/Model'. - Fix • Revert the changes to the referenced model.
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
modelBlock
— Model block to refresh
character vector | handle
Model block to refresh, specified as a character vector or a handle.
Example: 'RefreshModelBlockModel/Model'
Data Types: char
| string
| double
Version History
Introduced in R2020a
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)