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. The format of the model file is described in Appendix B, "Model File Format.

If you are saving a model for the first time, use the Save command to provide a name and location to the model file. Model file names must start with a letter and can contain no more than 31 letters, numbers, and underscores.

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.

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.


 Modeling a Simple Continuous System Printing a Block Diagram