##  Class files

You can use the mcode package by Florian Knorn, which is available as an example project on Overleaf. Later versions of mcode may be available for download from the MathWorks® File Exchange—you may need to sign-up for an account prior to downloading the package. Other sources of information include: Answers to this tex.stackexchange question; this detailed post by Yukio Fukuzawa on his blog on producing High quality graphics for your LaTeX document: The Matlab route, which may also be of interest.