Main Content

Rebuild

(To be removed) Rebuild policy for model reference targets

Model Configuration Pane: Model Referencing

The Rebuild configuration parameter will be removed in a future release. To prepare for this change, set Rebuild to If changes in known dependencies detected. For more information, see Version History.

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 this configuration parameter.

Settings

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

Conditionally rebuild model reference targets when the software detects a change that could affect simulation or code generation results. When the software finds no changes, the software does not compute the structural checksum of the model and does not rebuild the model reference target.

The software rebuilds the model reference targets only when:

  • A dependency automatically identified by the software has changed, and the change affects the current model.

  • A dependency manually specified by the Model dependencies configuration parameter has changed, and the change affects the current model.

When needed, the software determines whether the change affects the current model by checking whether the structural checksum has changed.

This flow chart visualizes how the software determines whether to rebuild model reference targets during model compilation, simulation, and code generation.

Flow chart for when to rebuild model reference targets

To prevent invalid simulation and code generation results, use the Model dependencies configuration parameter to specify files that contain code executed by callbacks. For more information, see Model dependencies.

Always

Unconditionally rebuild model reference targets. This setting requires the most processing time because this setting can trigger unnecessary builds.

If changes detected

Conditionally rebuild model reference targets when the software detects a change that could affect simulation or code generation results. When the software finds no changes, the software computes the structural checksum of the model. If the structural checksum has changed, the software rebuilds the model reference target.

Never

Do not rebuild model reference targets. This setting requires the least processing time. However, if model reference targets are out of date, the simulation or code generation can present invalid results. To manually rebuild model reference targets, use the slbuild function.

Examples

expand all

In this example, the Rebuild configuration parameter of the top model in a model hierarchy is set to If changes in known dependencies detected. You have model reference simulation targets for the referenced models that simulate in accelerator mode.

Suppose you change the value of a variable in a MAT file that provides data to the model workspace of a referenced model. Then, you simulate the model hierarchy.

  1. The software automatically identifies the change to the model workspace.

  2. The software determines that this type of change affects the model reference simulation target.

  3. The software rebuilds the model reference simulation target.

Next, suppose you change a file that contains code that executes as part of a callback script. Then, you simulate the model hierarchy.

  1. The software does not automatically identify the change to the code.

  2. The software checks the Model dependencies configuration parameter and finds a manually specified dependency on the file.

  3. The software checks the structural checksum of the referenced model. The structural checksum has changed, and the software rebuilds the model reference simulation target.

Unlike the MAT file case, in the callback-script case, you must specify the file as a model dependency with the Model dependencies configuration parameter. Otherwise, the software does not check the structural checksum or rebuild the model reference simulation target, and the model reference target remains out of date.

Tips

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: "IfOutOfDate" (since R2026a)

Limitations

This configuration parameter does not apply to a Model block when both of these conditions apply:

  • The block simulates in software-in-the-loop (SIL) or processor-in-the-loop (PIL) mode.

  • The Code interface block parameter is set to Top model.

In this case, the code regeneration behavior for the referenced model is what you observe for a standalone model. For more information, see Control Regeneration of Top Model Code (Embedded Coder).

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