How can I include MATLAB code in my LaTeX document?
You can use the listings package to include snippets of matlab code, and there's also a package called mcode that you can get here:
and upload to Overleaf, which further simplifies the process. There's an example project on Overleaf (with mcode and the listings package already included) that you can explore to get started.
There's also a 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.