Home / Articles / What's an M File and How Do You Open One?

What's an M File and How Do You Open One?

What's an M File and How Do You Open One? Image
  • Posted on 20th Jul, 2022 12:21 PM
  • 1145 Views

An M file is a text-based source code file created and used by various programs. Learn how to open one or how to convert one to PDF, EXE, etc.

What to Know

  • Most M files are source code files.
  • If a text editor doesn't display the file correctly, try MATLAB or Mathematica.
  • Text-based M files can be converted to other text formats with those same programs.

This article explains what an M file is and how to open one on your computer or convert one to a different file format. There are several types of M files, so it's important to know which one you have so you know what program you need to open it.

What Is an M File?

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 is the MATLAB source code 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. The file works the same way as running commands through the MATLAB command line, but makes 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 this 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 source code files written in the Mercury programming language.

It's unlikely that this is the type of file you have, but yet another use for this file extension is for music 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 text editor like Notepad in Windows or Notepad++.

However, MATLAB M files aren't 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 it with a text editor, but the same concept applies to MATLAB files in that they're only usable within the context of Mathematica.

Since class implementation files are text, 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-related files are similar to the other text-based file formats from above, but are 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. You can grab them from this download page.

How to Convert an M File

Most of the text editors linked on this page can convert an M file to another text-based format, like HTML or TXT. This only applies to the text formats, though, 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 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 these files to EXE for use with MATLAB Runtime, which allows MATLAB apps to run on computers that don't have the software installed.

Still Can't Open It?

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 working with the M openers or converters from above.

This 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 it as a text document. There might be some words or phrases in there that give away the program that made it, or describe what's used to open it.

FAQ
  • What are M files in C++?

    The MATLAB Coder in MATLAB produces C++ code from M files. You can use the converted code as source code in projects or add it to other code libraries. Learn more about generating C++ Code with MATLAB Coder.

  • What are M files with tildes?

    If you enable autosave in MATLAB in a UNIX environment, the tilde character appears after the M extension in the file name. To manage your autosave settings, select File > Preferences > Editor/Debugger > Autosave. You can also turn off autosave from this menu.

Was this page helpful?
What's an M File and How Do You Open One? View Story

Latest 20 Post