M-files in Matlab allow users to write multiple lines of code and store it in a file to execute later. There are two main types of m-files: scratch files and function files. Scratch files store code that can be run as a batch, while function files define custom functions that can be called. This document describes how to create both types of files, including naming conventions and basic syntax. It provides an example of a scratch file to plot a function and a function file to calculate sine in degrees rather than radians.