This article explains what an M file is and how you can open one on your computer or convert it to another file format. There are several different types of M files, so it's important to know which one you have so you know what program to use to open it.
Introduction to the M-Files Desktop User Interface
A file with the file extension M can belong to one of several file formats, but many of them are related to a source code file in some way.
One is the MATLAB source code format. These are text files that store scripts and functions for the MATLAB program to perform mathematical actions to plot graphs, execute algorithms, and more. The file works similarly to executing commands through the MATLAB command line, but makes it much easier to re-execute common actions.
A similar use for M files is with the Mathematica program. It is also a text-based file format that stores instructions that the program can use to perform certain mathematical functions.