Main Content

Manage Model Versions and Specify Model Properties

In Simulink®, you can manage multiple versions of a model using these techniques:

  • Use projects to manage your project files, connect to source control, review modified files, and compare revisions. See Project Management.

  • Use model file change notifications to manage work with source control operations and multiple users. See Model File Change Notification.

  • Use Simulink.MDLInfo to extract information from a model file without loading the block diagram into memory. You can use MDLInfo to query model version and Simulink version, find the names of referenced models without loading the model into memory, and attach arbitrary metadata to your model file.

Model File Change Notification

You can use a Simulink preference to specify whether to notify you if the model has changed on disk. You can receive this notification when updating or simulating the model, first editing the model, or saving the model. The model can change on disk, for example, with source control operations and multiple users.

In the Simulink Editor, on the Modeling tab, select Environment > Simulink Preferences. In the Model File pane, under Change Notification, you can select these options:

  • If you select First editing the model, the file has changed on disk, and the block diagram is unmodified in Simulink:

    • Any interactive operation that modifies the block diagram (for example, adding a block) causes a warning to appear.

    • Any command-line operation that modifies the block diagram (such as a call to set_param) causes a warning to appear.

  • If you select Saving the model, and the file has changed on disk:

    • Saving the model in the Simulink Editor causes a message to appear.

    • The save_system function reports an error, unless you use the OverwriteIfChangedOnDisk option.

To programmatically check whether the model has changed on disk since it was loaded, use the function slIsFileChangedOnDisk.

For more options that help you work with source control and multiple users, see Project Management.

Manage Model Properties

You can use the Property Inspector to view and edit model version properties, description, and callback functions. To open the Property Inspector, in the Modeling tab, under Design, click Property Inspector. Model properties or, if you are in a library model, library properties, appear in the Property Inspector when nothing is selected at the top level of a model.

Specify the Current User

When you create or update a model, your name is logged in the model. Simulink assumes that your name is specified by at least one of the USER, USERNAME, LOGIN, or LOGNAME environment variables. If your system does not define any of these variables, Simulink does not update the user name in the model.

UNIX® systems define the USER environment variable and set its value to the name you use to log in to your system. Thus, if you are using a UNIX system, you do not have to take further action for Simulink to identify you as the current user.

Windows® systems can define environment variables for user name that Simulink expects, depending on the version of Windows installed on your system and whether it is connected to a network. Use the MATLAB® function getenv to determine which of the environment variables is defined. For example, at MATLAB Command Window, enter:

getenv('user')

This function determines whether the USER environment variable exists on your Windows system. If it does not, set it.

Model Information

The Info tab summarizes information about the current version of the model, such as modifications, version, and the last saved date. You can view and edit model information and enable, view, and edit the model change history.

Use the Description section to enter a description of the model. You can then view the model description by entering help followed by the model name at the MATLAB Command Window.

  • Model version

    Version number for this model. The major model version is incremented by the number of releases passed since the model was last saved. The minor model version is reset to zero for every new release of Simulink and is incremented by one each time you save the model within the same release.

  • Created by

    Name of the person who created this model based on the value of the USER environment variable when the model is created.

  • Created on

    Date and time this model was created. Do not change this value.

  • Last saved by

    Name of the person who last saved this model based on the value of the USER environment variable when the model is saved.

  • Last saved on

    Date that this model was last saved, based on the system date and time.

Properties

You can view the source file location, set the model compression level, specify where to save model design data, and define callbacks in the Properties tab of the model properties.

Note

Library properties also enable you to specify the mapping from old library blocks to new library blocks. For information on using forwarding tables for this purpose, see Maintain Compatibility of Library Blocks Using Forwarding Tables.

Set SLX Compression Level.  In the Properties tab of the Property Inspector, you can select one of three SLX Compression options:

  • None applies no compression during the save operation. Turning off compression results in larger SLX files on disk, but reduces repository size.

  • Normal creates the smallest file size.

  • Fastest creates a smaller file size than you would get by selecting None, but provides a faster save time than Normal.

To set the compression level programmatically, use SLXCompressionType.

Staring in R2023b, by default, Simulink applies no compression during the save operation.

Before R2023b, to reduce your Git™ repository size, save Simulink models without compression. To use this setting with new SLX files, create your models using a model template with SLX Compression set to None. See Create Template from Model. For existing SLX files, set the compression and then save the model.

Define Location of Design Data.  Use the External Data section to specify the location of the design data that your model uses. You can define design data in the base workspace or in a data dictionary. See Migrate Single Model to Use Dictionary.

Callbacks.  Use the Callbacks section to specify functions to invoke at specific points during the simulation of the model. Select the callback from the list. In the box, enter the function you want to invoke for the selected callback. For information on these callbacks, see Create Model Callbacks.

Access Model Information Programmatically

Some version information is stored as model parameters in a model. You can access this information programmatically using the Simulink get_param function.

The table describes the model parameters used by Simulink to store version information.

PropertyDescription

BlockDiagramType

Returns model if it is in an open Simulink block diagram. Returns library if it is a Simulink library.

Created

Date created.

Creator

Name of the person who created this model.

Description

User-entered description of this model. In the Property Inspector, on the Info tab, enter or edit a description for the model in the Description box. To view the model description at the MATLAB Command Window, enter:

help 'mymodelname'

Dirty

If the value of this parameter is on, the model has unsaved changes.

FileName

Absolute path where the model is saved.

LastModifiedBy

Name of the user who last saved the model.

LastModifiedDate

Date when the model was last saved.

MetaData

Names and attributes of arbitrary data associated with the model. For more details, see Simulink.MDLInfo.getMetadata.

ModifiedByFormat

Format of the ModifiedBy parameter. The value can include the tag %<Auto>. The Simulink software replaces the tag with the current value of the USER environment variable.

ModifiedDateFormat

Format used to generate the value of the LastModifiedDate parameter. The value can include the tag %<Auto>. Simulink replaces the tag with the current date and time when saving the model.

ModelVersion

The major model version is incremented by the number of releases passed since the model was last saved. The minor model version is reset to zero for every new release of Simulink and is incremented by one each time you save the model within the same release.

ModelVersionFormat

The value contains the model format version as %<AutoIncrement:#.#> where # is an integer. Simulink increments the model version by # when saving the model.

PreviousFileName

When a PreSaveFcn or PostSaveFcn callback is running, PreviousFileName indicates the absolute path of the model before the save operation started.

To find the current absolute path of the model, use FileName instead.

SavedSinceLoaded

Indicates whether the model has been saved since it was loaded. 'on' indicates the model has been saved.

VersionLoaded

Simulink version that last saved the model, e.g., '7.6'.

EnableAccessToBaseWorkspace

Whether the model has access to design data and configuration sets in the base workspace, specified as 'true' or 'false'.

LibraryVersion is a block parameter for a linked block. LibraryVersion is the ModelVersion of the library at the time the link was created.

For source control version information, see Project Management.

See Also

Related Topics