Main Content

Simulink.BlockDiagram.getChecksum

Return model checksum

Syntax

[checksum,details] = Simulink.BlockDiagram.getChecksum('model')

Description

[checksum,details] = Simulink.BlockDiagram.getChecksum('model') returns the checksum of the specified model. Simulink® software computes the checksum based on these factors:

  • Attributes of the model

  • Attributes of the blocks in the model

  • Whether the model is simulated, built as a top model, or built as a referenced model

One use of this command is to determine why the Accelerator mode in Simulink software regenerates code. For an example, see Determine Why Simulink Accelerator Is Regenerating Code.

Note

Simulink.BlockDiagram.getChecksum compiles the specified model, if the model is not already in a compiled state.

This command accepts the argument model, which is the full name or handle of the model for which you are returning checksum data.

This command returns the following output:

  • checksum — Array of four 32-bit integers that represents the model's 128-bit checksum.

  • details — Structure of the form

    ContentsChecksum: [1x1 struct]
    InterfaceChecksum: [1x1 struct]
    ContentsChecksumItems: [nx1 struct]
    InterfaceChecksumItems: [mx1 struct]
    • ContentsChecksum — Structure of the following form that represents a checksum that provides information about all blocks in the model.

      Value: [4x1 uint32]
      MarkedUnique: [bool]
      • Value — Array of four 32-bit integers that represents the model's 128-bit checksum.

      • MarkedUnique — True if any blocks in the model have a property that prevents code reuse.

    • InterfaceChecksum — Structure of the following form that represents a checksum that provides information about the model.

      Value: [4x1 uint32]
      MarkedUnique: [bool]
      • Value — Array of four 32-bit integers that represents the model's 128-bit checksum.

      • MarkedUnique — Always true. Present for consistency with ContentsChecksum structure.

    • ContentsChecksumItems and InterfaceChecksumItems — Structure arrays of the following form that contain information that Simulink software uses to compute the checksum for ContentsChecksum and InterfaceChecksum, respectively:

      Handle: [char array]
      Identifier: [char array]
      Value: [type]
      
      • Handle — Object for which Simulink software added an item to the checksum. For a block, the handle is a full block path. For a block port, the handle is the full block path and a character vector that identifies the port.

      • Identifier — Descriptor of the item Simulink software added to the checksum. If the item is a documented parameter, the identifier is the parameter name.

      • Value — Value of the item Simulink software added to the checksum. If the item is a parameter, Value is the value returned by

        get_param(handle, identifier)

Simulink.BlockDiagram.getChecksum returns a checksum that depends on why and how you compiled the model. This function also compiles the model if it is not in a compiled state. The model compiles for:

  • Simulation— if the simulation mode is Accelerator or you have not installed Simulink Coder™

  • Code generation— in all other cases

To compile the model before calling Simulink.BlockDiagram.getChecksum, use this command, replacing modelName with the name of your model:

modelName([],[],[],'compile')

Note

The checksum that Simulink.BlockDiagram.getChecksum returns can vary from the checksum returned if you first compile the model programmatically using the model name programmatic interface (see Use Model Name as Programmatic Interface) before calling Simulink.BlockDiagram.getChecksum.

Tip

The structural checksum reflects changes to the model that can affect the simulation results, including:

  • Changing the solver type, for example from Variable-step to Fixed-step

  • Adding or deleting blocks or connections between blocks

  • Changing the values of nontunable block parameters, for example, the Seed parameter of the Random Number block

  • Changing the number of inputs or outputs of blocks, even if the connectivity is vectorized

  • Changing the number of states or the initial states in the model

  • Selecting a different function in the Trigonometric Function block

  • Changing signs used in a Sum block

  • Adding a Target Language Compiler (TLC) file to inline an S-function

Examples of model changes that do not affect the structural checksum include:

  • Changing the position of a block

  • Changing the position of a line

  • Resizing a block

  • Adding, removing, or changing a model annotation

Version History

Introduced in R2006b