What Is an M File?

How to open, edit, and convert M files

Screenshot of several M files used with Notepad in Windows 10
M Files.

A file with the M file extension could belong to one of several file formats, but many of them are related in some way to a source code file.

One type of M file is the MATLAB Source Code file format. These are text files that store scripts and functions for the MATLAB program to use for running mathematical actions to plot graphs, run algorithms, and more.

MATLAB M files work the exact same way as running commands through the MATLAB command line but make it much easier to re-run common actions.

A similar use for M files is with the Mathematica program. It's also a text-based file format that stores instructions that the program can use to run certain math-related functions.

Objective-C Implementation files use the M file extension too. These are text files that hold variables and functions used within the context of application programming, usually for macOS and iOS devices.

Some M files are instead Mercury Source Code files that are written in the Mercury programming language.

It's unlikely that this is the type of file you have but yet another use for the M file extension is for PC-98 Game Music song files that are used to emulate instruments on Japanese PC-98 computers.

How to Open an M File

MATLAB Source Code files can be created by and opened with a simple text editor, so Notepad in Windows, Notepad++, and other similar programs can be used to open the M file.

However, MATLAB M files are not actually usable unless they're opened within the MATLAB program. You can do this through the MATLAB prompt by entering the filename, like myfile.m.

M files used by Mathematica will of course open with that program. Since they're just text files, this also means that you can open this kind of M file with a text editor, but the same concept applies to MATLAB files in that they're only usable within the context of Mathematica.

Since Objective-C Implementation files are text files, they can be used with any text editor already mentioned, including ones like jEdit and Vim. However, these M files aren't applicable until they're utilized with Apple Xcode or some other related compiler.

Mercury Source Code files are similar to the other text-based file formats from above but is really only useful with winmercury or this Mercury compiler.

PC-98 M files can be opened with FMPMD2000. You also need to make sure that you've got two DLL files - WinFMP.dll and PMDWin.dll - which you can grab from this download page.

How to Convert an M File

Most of the text editors mentioned on this page can convert an M file to another text-based format like HTML or TXT. This of course only applies to the text formats and not something else like a PC-98 audio file.

To save the code in an M file to PDF is possible with MATLAB. With the M file open, look for an Edit M File Configuration or some sort of Export or Save as menu.

If you want to convert a different M file to PDF - one that isn't related to MATLAB, try one of these free PDF printers.

MATLAB Compiler can convert MATLAB M files to EXE for use with MATLAB Runtime, which allows MATLAB apps to run on computers that don't have MATLAB installed.

Is Your File Still Not Opening?

Some files are easily confused with others because their file extensions share common letters. It's possible that you don't really have an M file and that's why it's not opening with the M openers or converters from above.

The M file extension is clearly just one letter long, so while it might seem unlikely that you'd get it mixed up with a different file that belongs to a different file format, it's still important to double-check.

For example, there are several file formats that use M to identify the file, like M3U, M2 and M3 (Blizzard object or model), M4A, M4B, M2V, M4R, M4P, M4V, etc. If you check the file extension of your file and notice that it belongs to one of those formats, then use the link provided or research the suffix to learn how to open it.

If you do in fact have an M file but it's not opening with the suggestions on this page, it's possible that you have a really obscure format. Use a text editor like Notepad++ to open the M file and read it as a text document. There might be some words or phrases in there that give away the program that made it or is used to open it.

Was this page helpful?