| Simulink® | ![]() |
| On this page… |
|---|
Saving Models with Different Character Encodings Saving a Model in Earlier Formats Opening Models Originally Created in an Older Version of Simulink® |
You can save a model by choosing either the Save or Save As command from the File menu. The model is saved by generating a specially formatted file called the model file (with the .mdl extension) that contains the block diagram and block properties.
If you are saving a model for the first time, use the Save command to provide a name and location for the model file. Model file names must start with a letter and can contain letters, numbers, and underscores. The total number must not be greater than a certain maximum, usually 63 characters. You can use the MATLAB® software namelengthmax namelengthmax command to find out if the maximum is greater than 63 characters for your system. The file name must not be the same as that of a MATLAB software command.
If you are saving a model whose model file was previously saved, use the Save command to replace the file's contents or the Save As command to save the model with a new name or location. You can also use the Save As command to save the model in a format compatible with previous releases of the Simulink® product (see Saving a Model in Earlier Formats).
The Simulink software follows this procedure while saving a model:
If the mdl file for the model already exists, it is renamed as a temporary file.
All block PreSaveFcn callback routines are executed first, then the block diagram's PreSaveFcn callback routine are executed.
The model file is written to a new file using the same name and an extension of mdl.
All block PostSaveFcn callback routines are executed, then the block diagram's PostSaveFcn callback routine is executed.
If an error occurs during this process, the Simulink software renames the temporary file to the name of the original model file, writes the current version of the model to a file with an .err extension, and issues an error message. If an error occurs in step 2, step 3 is omitted and steps 4 and 5 are performed.
When a model is saved, the character encoding in effect when the model was created (the original encoding) is used to encode the text stored in the model's .mdl file, regardless of the character encoding in effect when the model is saved. This can lead to model corruption if you save a model whose original encoding differs from encoding currently in effect.
For example, it's possible you could have introduced characters that cannot be represented in the model's original encoding. If this is the case, the model is saved as model.err where model is the model's name, leaving the original model file unchanged. The Simulink software also displays an error message that specifies the line and column number of the first unrepresentable character. To recover from this error without losing all the changes you've made to the model in the current session, use the following procedure. First, use a text editor to find the character in the .err file at the position specified by the save error message. Then, find and delete the corresponding character in the open model and resave the model . Repeat this process until you are able to save the model without error.
It's possible that your model's original encoding can represent all the text changes that you've made in the current session, albeit incorrectly. For example, suppose you open a model whose original encoding is A in a session whose current encoding is B. Further, suppose you edit the model to include a character that has different encodings in A and B and then save the model. For example, suppose that the encoding for x in B is the same as the coding for y in A and you insert x in the model while B is in effect, save the model, and then reopen the model with A in effect. In this scenario, the Simulink software will display x as y. To alert you to the possibility of such corruptions, the software displays a warning message when you save a model and the current and original encoding differ but the original encoding can encode, possibly incorrectly, all the characters to be saved in the model file.
The Save As command allows you to save a model created with the latest version of the Simulink software in formats used by earlier versions, including Simulink 4 (Release 12), Simulink 4.1 (Release 12.1), Simulink 5 (Release 13), Simulink 5.1 (Release 13SP1), and Simulink 6 (Release 14, compatible with Release 14, Release 14SP1, and Release 14SP2). You might want to do this, for example, if you need to make a model available to colleagues who have access only to one of these earlier versions of the Simulink product.
To save a model in earlier format:
Select Save from the File menu. This saves a copy in the latest version of Simulink. This step is necessary to avoid compatibility problems.
Select Save As from the File menu.
The Save As dialog box is displayed.

Select a format from the Save as type list on the dialog box.
When saving a model in an earlier version's format, the model is saved in the earlier format regardless of whether the model contains blocks and features that were introduced after that version. If the model does contain blocks or use features that postdate the earlier version, the model might not give correct results when run by the earlier version. For example, matrix and frame signals do not work in Release 11, because Release 11 does not have matrix and frame support. Similarly, models that contain unconditionally executed subsystems marked Treat as atomic unit might produce different results in Release 11, because Release 11 does not support unconditionally executed atomic subsystems.
The command converts blocks that postdate the earlier version into empty masked subsystem blocks colored yellow. For example, post-Release 11 blocks include
Lookup Table (n-D)
Assertion
Rate Transition
PreLookup Index Search
Interpolation (n-D)
Direct Lookup Table (n-D)
Polynomial
Matrix Concatenation
Signal Specification
Bus Creator
If, WhileIterator, ForIterator, Assignment
SwitchCase
Bitwise Logical Operator
Post-Release 11 blocks from blocksets appear as unlinked blocks.
Opening models originally created in an older version of Simulink and then using Save as can cause compatibility problems unless they are first saved with the most recent Simulink version and then opened and saved with the older version of Simulink.
Use the following procedure if you wish to open a model created in an older version of Simulink, and wish to save it to some other version:
Open the older model with the most recent version of Simulink available to you
Before making any changes, use Save to save the model in the most recent version of Simulink available to you
If you wish to modify or run the model, do so at this step
Use Save as to save the model in an older Simulink version. Start the older version of Simulink and use it to open the just saved model
While still in the older version of Simulink, but before making any changes or running the model, use Save to save the model. You can now run the model in the older version of Simulink.
![]() | Updating a Block Diagram | Printing a Block Diagram | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |