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.
Simulink.MDLInfo to extract information from a model
file without loading the block diagram into memory. You can use
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 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.
save_system function reports
an error, unless you use the
To programmatically check whether the model has changed on disk
since it was loaded, use the function
For more options that help you work with source control and multiple users, see Project Management.
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.
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
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
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
determine which of the environment variables is defined. For example,
at MATLAB command prompt, enter:
This function determines whether the
variable exists on your Windows system. If it does not, set it.
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 the model name at the MATLAB command prompt.
The History section displays model history information.
Version number for this model, incremented by 1 each time you save the model.
Name of the person who created this model based on the value
USER environment variable when the model
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
USER environment variable when the model
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.
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.
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.
To enable comment logging, in the Info tab
of the model properties, in the History section,
set Prompt to update model history to
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
Some version information is stored as model parameters in a
model. You can access this information programmatically using the Simulink
The 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 prompt.
Name of the user who last saved the model.
Date when the model was last saved.
Format of the
Format used to generate the value of the
Comment entered by user who last updated this model.
History of changes to this model.
Format of model version number. The value can contain
LibraryVersion is a block parameter for a
LibraryVersion is the
the library at the time the link was created.
For source control version information, see instead Project Management.