How and when to cite code from MATLAB File Exchange What are the rules/etiquette to cite MATLAB File-exchange submissions on paper publications? 

There are different scenarios where I am curious what is best:


FEX submission is clearly code from a paper written by the same person.
Code is from a paper, but the author of the code is not the same author than the paper.
Code is a nice tool, but has no available citation. E.g. inpaint_nans, nice tool to fill "missing" data.
Code that is a nice tool, someone coded it, but its little effort to rewrite as it's not a complex tool. Still, someone write it and, time==gold!
Code that is a nice tool, takes little effort to rewrite, but its code referencing more than one paper. E.g. 3D Shepp-Logan Phantom, references 2 papers, and its a short function.


MATLAB uses the BSD license in FEX, meaning all software can be used and redistributed as long as the copyright is maintained an disclaimer kept.

This means that legally, one can just copy-paste the code and use it without any worry, as long as the license file is kept. But law aside, how should one act in the above mentioned cases?
This answer is from my own personal experience in academia and may/may not be strictly SOP, however, I'll do my best to answer.  Most of this is assuming that you have not drastically altered the original code for your work.

1) FEX submission is clearly code from a paper written by the same person.

In this case, contact the person and let them know you are using their code in your work, cite their paper, and acknowledge their code in the paper.  This is especially important if their code was critical to your work.

2) Code is from a paper, but the author of the code is not the same author than the paper.

Cite the original paper as it is providing the basis of the code that you are using.  Contact the author of the code and acknowledge them.

3) Code is a nice tool, but has no available citation. E.g. inpaint_nans, nice tool to fill "missing" data.

This is an example of when the code doesn't accomplish the goal of the research and is therefore not going to be mentioned in the paper.  In this case, you can acknowledge the author in your own code/ software, but not in your paper.

4) Code that is a nice tool, someone coded it, but its little effort to rewrite as it's not a complex tool. Still, someone write it and, time==gold!

In this case, it is probably not even worth any mention.  I think everyone on the exchange understands at some point, contributions are designed to further programming itself, not themselves.

5) Code that is a nice tool, takes little effort to rewrite, but its code referencing more than one paper. E.g. 3D Shepp-Logan Phantom, references 2 papers, and its a short function.

In this example, this code is copyright protected but also released under GPL. Follow the procedure for GPL and when in doubt, contact the author.  If the code is central to your work, acknowledge the author at the end of your paper.

Summary: If the code is central to your research theme, contact the author.  If the code is a tool that 'fills in the blanks', it doesn't need to appear in the paper, but should be referenced in your code.