| Contents | Index |
| On this page… |
|---|
How Simulink Helps You Manage Model Versions Model File Change Notification |
The Simulink software has these features to help you to manage multiple versions of a model:
Model File Change Notification helps you manage work with source control operations and multiple users
As you edit a model, the Simulink software generates version control information about the model, including a version number, who created and last updated the model, and an optional change history. The Simulink software automatically saves these Version Control Properties with the model
The Model Properties dialog box lets you edit some of the version control information stored in the model and select various version control options
The Model Info block lets you display version control information, including information maintained by an external version control system, as an annotation block in a model diagram
The Simulink software version control parameters let you access version control information from the MATLAB command line or a MATLAB script
The Source Control submenu of the File menu allows you to check models into and out of your source control system. See Source Control Interface in the online MATLAB documentation for more information.
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,
Select File > Preferences in the Simulink product.
Select File > Preferences in MATLAB to open the MATLAB Preferences, then select Simulink in the left pane, and click the button Launch Simulink Preferences.

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.
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
getenv('user')
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, use the Environment variables pane of the System Properties dialog box to set the USER environment variable (if it is not already defined). For Windows XP, access the Environment variables pane by clicking the Environment Variables button on the Advanced pane of the System Properties dialog box.

To display the System Properties dialog box, select Start > Settings > Control Panel to open the Control Panel. Double-click the System icon. To set the USER variable, enter USER in the Variable field and enter your login name in the Value field. Click Set to save the new environment variable. Then click OK to close the dialog box.
The Model Properties dialog box allows you to set various version control parameters and model callback functions. To display the dialog box, choose Model Properties from the File menu.

The dialog box includes the following panes.
The Main pane summarizes information about the current version of this model.
The Callbacks pane lets you 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 Creating Model Callback Functions for information on the callback functions listed on this pane.
The History pane allows you to enable, view, and edit this model's change history.

The History pane has two control groups: the Model information group and the Model History group.
The contents of the Model information control group depend on the state of the Read Only check box.
Read Only Check Box Selected. When Read Only is selected, the dialog box shows the following fields grayed out.
Created by
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.
Created on
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.
Model version
Version number for this model.
Read Only Check Box Deselected. When Read Only 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.

Created by
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.
Created on
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>. The Simulink software 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.
Model version
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. The Simulink software replaces the tag with an integer when displaying the model's version number. For example, it displays the tag
1.%<AutoIncrement:2>
as
1.2
The Simulink software increments # by 1 when saving the model. For example, when you save the model,
1.%<AutoIncrement:2>
becomes
1.%<AutoIncrement:3>
and the model version number is reported as 1.3.
The model history controls group contains a scrollable text field and an option list. The text field displays the history for the model in a scrollable text field. To change the model history, edit the contents of this field. The option list allows you to enable or disable the Simulink software model history feature. To enable the history feature, select When saving model from the Prompt to update model history list. This causes the Simulink software to prompt you to enter a comment when saving the model. Typically you would enter any changes that you have made to the model since the last time you saved it. This information is stored in the model's change history log. See Creating a Model Change History for more information. To disable the change history feature, select Never from the Prompt to update model history list.
This pane allows you to enter a description of the model. When 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.
To start a change history, select When saving model from the Prompt to update model history list on the History pane on the Model Properties dialog box. The next time you save the model, a Log Change dialog box is displayed.

To add an item to the model's change history, enter the item in the Modified Comments edit field and click Save. If you do not want to enter an item for this session, clear the Include "Modified Contents" in "Modified History" option. To discontinue change logging, clear the Show this dialog box next time when save option.
Version control 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 control information.
![]() | Consulting the Model Advisor | Model Discretizer | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |