|On this page…|
The Simulink® software has these features to help you to manage multiple versions of a model:
Use Simulink Projects to manage your project files, connect to source control, review modified files and compare revisions. See Project Management .
Model File Change Notification helps you manage work with source control operations and multiple users. See Model File Change Notification.
As you edit a model, the Simulink software generates version information about the model, including a version number, who created and last updated the model, and an optional comments history log. The Simulink software automatically saves these version properties with the model.
Use the Model Properties dialog box to view and edit some of the version information stored in the model and specify history logging.
The Model Info block lets you display version information as an annotation block in a model diagram.
You can access Simulink version parameters from the MATLAB® command line or a MATLAB script.
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.
You can use the Simulink Preferences window to specify whether to notify if the model has changed on disk when updating, simulating, editing, or saving the model. This can occur, for example, with source control operations and multiple users.
Note: To programmatically check whether the model has changed on disk since it was loaded, use the function slIsFileChangedOnDisk.
To access the Simulink Preferences window, use one of these approaches:
In the Simulink Editor, select File > Simulink Preferences.
From the MATLAB Toolstrip, in the Home tab, in the Environment section, select Preferences > Simulink. Click the Launch Simulink Preferences button .
The Model File Change Notification options are in the right pane. You can use the three independent options as follows:
If you select the Updating or simulating the model check box, you can choose what form of notification you want from the Action list:
Warning — in the MATLAB command window.
Error — in the MATLAB command window if simulating from the command line, or if simulating from a menu item, in the Simulation Diagnostics window.
Reload model (if unmodified) — if the model is modified, you see the prompt dialog. If unmodified, the model is reloaded.
Show prompt dialog — in the dialog, you can choose to close and reload, or ignore the changes.
If you select the First editing the model check box, and the file has changed on disk, and the block diagram is unmodified in Simulink:
Any command-line operation that causes the block diagram to be modified (e.g., a call to set_param) will result in a warning:
Warning: Block diagram 'mymodel' is being edited but file has changed on disk since it was loaded. You should close and reload the block diagram.
Any graphical operation that modifies the block diagram (e.g., adding a block) causes a warning dialog to appear.
If you select the Saving the model check box, and the file has changed on disk:
The save_system function displays an error, unless the OverwriteIfChangedOnDisk option is used.
Saving the model by using the menu (File > Save) or a keyboard shortcut causes a dialog to be shown. In the dialog, you can choose to overwrite, save with a new name, or cancel the operation.
For more options to help you work with source control and multiple users, see Project Management .
When you create or update a model, your name is logged in the model for version control purposes. The Simulink software assumes that your name is specified by at least one of the following environment variables: USER, USERNAME, LOGIN, or LOGNAME. If your system does not define any of these variables, the Simulink software 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 on to your system. Thus, if you are using a UNIX system, you do not have to do anything to enable the Simulink software to identify you as the current user.
Windows® systems, on the other hand, might define some or none of the "user name" environment variables that the Simulink software expects, depending on the version of Windows installed on your system and whether it is connected to a network. Use the MATLAB command getenv to determine which of the environment variables is defined. For example, enter
at the MATLAB command line to determine whether the USER environment variable exists on your Windows system. If not, you must set it yourself.
On Windows, set the USER environment variable (if it is not already defined).
You can use the Model Properties dialog box to view and edit model information (including some version parameters), callback functions, history, and the model description. To open the dialog box,
In a model, select File > Model Properties.
In a library, select File > Library Properties.
Library Properties includes an additional tab, Forwarding Table, for specifying the mapping from old library blocks to new library blocks. For information on using the Forwarding Table, see Make Backward-Compatible Changes to Libraries.
Model Properties and Library Properties both include the tabs Main Model Information, Callbacks, History and Description. The controls in the shared tabs are described next on this page.
The dialog box includes the following panes.
The Main pane summarizes information about the current version of this model, such as whether the model is modified, the Model Version, and Last Saved date. You can edit some of this information in the History tab, see Viewing and Editing Model Information and History.
Use the Callbacks pane to specify functions to be invoked at specific points in the simulation of the model.
In the left pane, select the callback. In the right pane, enter the name of the function you want to be invoked for the selected callback. See Create Model Callbacks for information on the callback functions listed on this pane.
Use the History pane to view and edit model information, and to enable, view, and edit this model's change history in the lower Model history field. To use the history controls see Log Comments History.
Name of the person who created this model. The Simulink software sets this property to the value of the USER environment variable when you create the model.
Date and time this model was created.
Last saved by
Name of the person who last saved this model. The Simulink software sets the value of this parameter to the value of the USER environment variable when you save a model.
Last saved on
Date that this model was last saved. The Simulink software sets the value of this parameter to the system date and time whenever you save a model.
Version number for this model.
Editing Model Information. Clear the Read Only check box to edit model information. When the check box is deselected, the dialog box shows the format strings or values for the following fields. You can edit all but the Created on field, as described.
Name of the person who created this model. The Simulink software sets this property to the value of the USER environment variable when you create the model. Edit this field to change the value.
Date and time this model was created. Do not edit this field.
Last saved by
Enter a format string describing the format used to display the Last saved by value in the History pane and the ModifiedBy entry in the history log and Model Info blocks. The value of this field can be any string. The string can include the tag %<Auto>. Simulink replaces occurrences of this tag with the current value of the USER environment variable.
Last saved on
Enter a format string describing the format used to display the Last saved on date in the History pane and the ModifiedOn entry in the history log and the in Model Info blocks. The value of this field can be any string. The string can contain the tag %<Auto>. The Simulink software replaces occurrences of this tag with the current date and time.
Enter a format string describing the format used to display the model version number in the Model Properties pane and in Model Info blocks. The value of this parameter can be any text string. The text string can include occurrences of the tag %<AutoIncrement:#> where # is an integer. Simulink replaces the tag with an integer when displaying the model's version number. For example, it displays the tag
Simulink increments # by 1 when saving the model. For example, when you save the model,
and the model version number is reported as 1.3.
Use the Description pane to enter a description of the model. You can view the model description by typing help followed by the model name at the MATLAB prompt. The contents of the Model description field appear in the Command Window.
You can create and store a record of changes to a model in the model itself. The Simulink software compiles the history automatically from comments that you or other users enter when they save changes to a model. For more flexibility adding labels and comments to models and submissions, see instead Project Management .
To start a change history,
Select File > Model Properties.
In the Model Properties dialog box, select the History tab.
In the Prompt to update model history list, select When saving model and click OK.
The next time you save the model, the Add Comment to Model History dialog box prompts you to enter a comment.
For example you could describe changes that you have made to the model since the last time you saved it. To add an item to the model's change history, enter the item in the Comment edit field 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, either:
In the Add Comment to Model History dialog box, clear the check box Always prompt to update model history when saving this model.
In the Model Properties dialog box History pane, select Never from the Prompt to update model history list.
In the Model Properties dialog box you can view and edit the model history on the History tab.
The model history text field displays the history for the model in a scrollable text field. To change the model history, edit the contents of this field.
Some version information is stored as model parameters in a model. You can access this information from the MATLAB command line or from a MATLAB script, using the Simulink get_param command.
The following table describes the model parameters used by Simulink to store version information.
Name of the person who created this model.
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
at the MATLAB command line.
Name of the user who last saved the model.
Date when the model was last saved.
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.
Format of the ModifiedBy parameter. Value can be any string. The string can include the tag %<Auto>. The Simulink software replaces the tag with the current value of the USER environment variable.
Format of the ModifiedDate parameter. Value can be any string. The string can include the tag %<Auto>. Simulink replaces the tag with the current date and time when saving the model.
Comment entered by user who last updated this model.
History of changes to this model.
Format of model version number. Can be any string. The string 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 .