Simulink.ModelReference.refresh - Force update to Model block to reflect changes to referenced model - MATLAB (original) (raw)
Main Content
Force update to Model block to reflect changes to referenced model
Syntax
Description
Examples
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).
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');
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
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, theModel blocks update only when the Model block version mismatch and Port and parameter mismatch configuration parameters are set tonone
or warning
. TheModel blocks do not update when either configuration parameter is set toerror
.
Alternative Functionality
Select a Model block. In the SimulinkĀ® Toolstrip, on the Model Block tab, clickRefresh .
Version History
Introduced in R2020a