Using Simulink    

Saving a Model

You can save a model by choosing either the Save or Save As command from the File menu. Simulink saves the model 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 no more than 63 letters, numbers, and underscores. The file name must not be the same as that of a MATLAB 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 Simulink (see Saving a Model in Earlier Formats).

Simulink follows this procedure while saving a model:

  1. If the mdl file for the model already exists, it is renamed as a temporary file.
  2. Simulink executes all block PreSaveFcn callback routines, then executes the block diagram's PreSaveFcn callback routine.
  3. Simulink writes the model file to a new file using the same name and an extension of mdl.
  4. Simulink executes all block PostSaveFcn callback routines, then executes the block diagram's PostSaveFcn callback routine.
  5. Simulink deletes the temporary file.

If an error occurs during this process, Simulink 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. Simulink performs steps 2 through 4 even if an error occurs in an earlier step.

Saving a Model in Earlier Formats

The Save As command allows you to save a model created with the latest version of Simulink in formats used by earlier versions of Simulink, including Simulink 3 (R11), Simulink 4 (R12), and Simulink 4.1 (R12.1). 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 Simulink.

To save a model in earlier format:

  1. Select Save As from the Simulink File menu.
  1. Simulink displays the Save As dialog box.

  1. Select a format from the Save as type list on the dialog box.
  2. Click the Save button.

When saving a model in an earlier version's format, Simulink saves the model in that 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 R11, because R11 does not have matrix and frame support. Similarly, models that contain unconditionally executed subsystems marked "Treat as atomic unit" might produce different results in R11, because R11 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-R11 blocks include

Post-R11 blocks from Simulink blocksets appear as unlinked blocks.


  Simulink Windows Printing a Block Diagram