Main Content

Manage Model Versions and Specify Model Properties

How Simulink Helps You Manage Model Versions

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 notification to manage work with source control operations and multiple users. See Model File Change Notification.

  • See 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, select the appropriate action.

  • 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 (e.g., 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 prompt, 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 last saved date. You can view and edit model information and enable, view, and edit the model’s 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 prompt.

  • 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 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.

  • Normal, the default, 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.

Tip

You can reduce your Git™ repository size by saving Simulink models without compression. Turning off compression results in larger SLX files on disk but reduces repository size.

To use this setting with new SLX files, create your models using a model template with SLX Compression set to none. See Create a Template from a Model. For existing SLX files, set compression and then save the model.

Define Location of Design Data.  Use the Design 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 in 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

Created

Date created.

Creator

Name of the person who created this model.

Description

User-entered description of this model. Enter or edit a description on the Description tab of the Model Properties dialog box. You can view the model description by typing

help 'mymodelname' 
at the MATLAB command prompt.

Dirty

If the 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 # 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'.

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 instead Project Management.

See Also

Related Topics