Main Content

Rebuild

Option to conditionally, always, or never rebuild model reference targets

Model Configuration Pane: Model Referencing

Description

The Rebuild configuration parameter determines when to rebuild simulation and Simulink® Coder™ targets for referenced models before updating, simulating, or generating code from the model.

Models in a model hierarchy can have different rebuild settings. When you update, simulate, or generate code for a model, the rebuild setting for that model applies to all its referenced models.

Models that execute in normal mode do not generate simulation targets and are unaffected by the Rebuild settings.

Set Configuration Parameter for Referenced Model

In a model reference hierarchy, how you open the Configuration Parameters dialog box determines whether you edit the configuration parameter for the top model in the current model hierarchy or the current referenced model.

  • Top model in the current model hierarchy — In the Simulink Toolstrip, on the Modeling tab, click Model Settings.

  • Current referenced model — In the Simulink Toolstrip, on the Modeling tab, click the Model Settings button arrow. Then, in the Referenced Model section, select Model Settings.

Alternatively, open the referenced model as a top model. Then, in the Simulink Toolstrip, on the Modeling tab, click Model Settings.

Settings

If changes detected (default) | Always | If changes in known dependencies detected | Never
Always

Always rebuild targets for referenced models. This setting requires the most processing time because it can trigger unnecessary builds. To make all model reference targets up to date, use this setting before you deploy a model.

If changes detected

Conditionally rebuild targets for referenced models when the software detects a change that could affect simulation results. To perform extensive change detection on dependencies of referenced models, use this setting.

If the software finds no changes in known dependencies, it computes the structural checksum of the model. The structural checksum detects changes that occur in user-created dependencies that are not specified using the Model dependencies configuration parameter. If the structural checksum has changed, the software rebuilds the model reference target.

If changes in known dependencies detected

Conditionally rebuild targets for referenced models when the software detects a change that could affect simulation results. To reduce the time required for change detection, use this setting.

If the software finds no changes in known or potential dependencies, it does not compute the structural checksum of the model and does not rebuild the model reference target. To avoid invalid simulation results, you must list all user-created dependencies in the Model dependencies parameter.

Never

Do not rebuild targets for referenced models. This setting requires the least processing time and, when available, uses Simulink cache files for faster simulations. To avoid rebuilds when developing a model, use this setting.

If model reference targets are out of date, the simulation may present invalid results. To have the software check for changes in known target dependencies and report if the model reference targets may be out of date, use the Never rebuild diagnostic parameter. To manually rebuild model reference targets, use the slbuild function.

For information on using and sharing Simulink cache files, see Share Simulink Cache Files for Faster Simulation.

Examples

expand all

You can conditionally rebuild model reference targets by setting Rebuild to If changes detected or If changes in known dependencies detected.

Suppose you change a MATLAB® script that executes as part of a callback script. The Model dependencies configuration parameter does not list the MATLAB script as a model dependency.

The Rebuild setting determines whether to rebuild the affected model reference targets.

  • If changes detected causes a rebuild because the change affects the structural checksum of the model.

  • If changes in known dependencies detected does not cause a rebuild because no known target dependency has changed.

This flow chart describes the processing Simulink performs when you set Rebuild to either If changes detected or If changes in known dependencies detected.

Flow chart for when to rebuild model reference targets

For the If changes detected or If changes in known dependencies detected settings, model reference targets rebuild when:

  • A known target dependency has changed.

  • A model file or library has changed and the structural checksum has changed.

  • A potential target dependency trigger is detected and the structural checksum has changed.

  • None of the above apply, the Rebuild setting is If changes detected, and the structural checksum has changed.

Tips

To improve rebuild detection speed and accuracy, use the Model dependencies configuration parameter to specify user-created dependencies.

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precaution

If changes detected or Never

When you use the Never setting, set the Never rebuild diagnostic configuration parameter to Error if rebuild required.

Programmatic Use

Parameter: UpdateModelReferenceTargets
Value1 : 'Force' | 'IfOutOfDateOrStructuralChange' | 'IfOutOfDate' | 'AssumeUpToDate'
Default: 'IfOutOfDateOrStructuralChange'

More About

expand all

Version History

Introduced before R2006a

expand all


1 This table maps the programmatic values to the equivalent interactive values of the Rebuild configuration parameter.

UpdateModelReferenceTargets ValueEquivalent Rebuild Value
'Force'Always
'IfOutOfDateOrStructuralChange'If changes detected
'IfOutOfDate'If changes in known dependencies detected
'AssumeUpToDate'Never