Documentation

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

  • As you edit a model, Simulink generates version information about the model, including a version number, who created and last updated the model, and an optional comments history log. Simulink saves these version properties with the model.

    • View and edit some of the version information stored in the model and specify history logging in the model properties.

    • The Model Info block lets you display version information as an annotation block in a model diagram.

    • You can access Simulink version parameters programmatically.

  • 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, select File > 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 history, and callback functions. To open the Property Inspector, select View > 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 for version control purposes. 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 and History

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.

The History section displays model history information.

  • Model version

    Version number for this model, incremented by 1 each time you save the model.

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

The Model history box displays the history of the model. For more information on updating model history, see Log Comments History.

Properties

You can view the source file location, 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.

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.

Log Comments History

You can create and store a record of changes with the model. Simulink compiles the history from comments that you or other users enter when saving changes to a model. For more flexibility adding labels and comments to models and submissions, see Project Management.

Logging Changes

To enable comment logging, in the Info tab of the model properties, in the History section, set Prompt to update model history to When saving model.

The next time you save the model, the Add Comment to Model History dialog box prompts you to enter a comment.

For example, describe the changes you have made to the model since the last time you saved it. To add an item to the model's change history, enter it in the Comment box and click Save. The information is stored in the model's change history log.

If you do not want to enter an item for this session, clear the Add comment to model history check box.

To discontinue change logging, you can either:

  • Clear the Always prompt to update model history when saving this model check box.

  • Change the Prompt to update model history model property to Never.

Version Information Properties

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.

LastModifiedBy

Name of the user who last saved the model.

LastModifiedDate

Date when the model was last saved.

ModifiedBy

Current value of the user name of the person who last modified this model. When you save, this information is saved with the file as LastModifiedBy.

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.

ModifiedComment

Comment entered by user who last updated this model.

ModifiedHistory

History of changes to this model.

ModelVersion

Version number.

ModelVersionFormat

Format of model version number. The value can contain the tag %<AutoIncrement:#> where # is an integer. Simulink replaces the tag with # when displaying the version number. It increments # when saving the model.

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 Examples

Was this topic helpful?