I work a lot with MATLAB, and I want to enable the reader of my paper to easily reproduce my computations. I also want the pdf document to be self-contained, i.e., no hyperlinks to a webpage on which the code is available. Is there a good way to accomplish this in LaTeX?
Unfortunately, I find that authors frequently print their computer code in the paper, and the code might be broken over multiple pages, thereby making copy-and-paste a tedious task.
I envision two alternatives:
In the pdf, there is a link that when clicked, prompts the user to save an m file in a directory of his choosing. I do not want the m file to reside in a local network drive (as in this question), but rather, I want the m file code to somehow reside under the hood of the pdf (much like how the pdf includes graphics, say).
In the pdf, there is a text box with a scroll bar which contains my MATLAB code. If interested, the reader can easily copy and paste as desired.
I would be very happy to learn how to implement either of these (or other alternatives) in LaTeX. Thanks for the help!

.mfile to your pdf so that readers can get a copy. – May 08 '15 at 12:32pdfdocument even with LaTeX, e.g. the source code of your matlab files – May 08 '15 at 12:32