MATLAB Files and What They Do

By Jim Sizemore, John Paul Mueller

MATLAB provides specific file types for specific needs. To get the most out of MATLAB, you need to know about the different file types.The following list tells you about the MATLAB file types and describes their uses:

  • .fig: Provides access to any plots or other graphics you create. Keep in mind that the file contains all the information required to reconstruct the graphic, but does not contain the graphic itself. This approach means that your image is accessible on any platform that MATLAB supports.

    A lot of people have asked whether they can access .fig files without necessarily having to display the graphic image itself. It turns out that .fig files are actually .mat files in disguise. The file format is the same. This article describes how you can access .fig files in text format so that you can see what they contain without seeing the associated graphic.

  • .m: Holds a MATLAB script. This is a platform-independent file, so you can use the same scripts on whatever platform you’re working on at the time. This file also allows you to create a script on one platform and share it with others, even when they use a different platform than you do. MATLAB script files are always written using the MATLAB language.

  • .mat: Provides access to any data you saved on disk. Opening this file starts the Import Wizard to load the data into the MATLAB workspace.

  • .mdl: Contains an older version of a Simulink model (see .slx below for details on the Simulink model). MATLAB recommends updating these files to the .slx format.

  • .mex*: Contains compiled executable code that extends MATLAB functionality in some manner. You execute these files just as you would a script program. The original code is written in either FORTRAN or C++ and then compiled for a specific platform. Each platform has a unique extension associated with it, as shown in the following list:

    • .mexa64: Linux

    • .mexmaci64: Mac OS X

    • .mexw32: 32-bit Windows

    • .mexw64: 64-bit Windows

  • .p: Performs the same task as an .m file, except the content is protected from edits by anyone else. This feature lets you distribute your scripts to other people without fear of giving away programming techniques or trade secrets.

  • .slx: Contains a Simulink model. Simulink is an add-on product for MATLAB that provides a block diagram environment for performing simulations.