Am I allowed to write functions that have names of matlab functions (copyright)?

Hello everyone,
I am not really well versed when it comes to copyright laws. My question is, am I allowed to write a function and give it a name that exists as a Matlab function, for example from a toolbox? Am I allowed to share said functions?
I know that the code within a Matlab supplied function is copyrighted and is property of Matlab, but does this hold also for the names of the functions? For example, may i write my own function, which is called "mvnrnd.m"? Am I allowed to share such a function with someone else?
I can't imagine it would be, since I can have that function name in another coding language and i don't see how Mathworks can sue the other company for something so generic, but I prefer to ask anyways.
I am leaving aside the obvious coding issue if you have two functions with the same name.

11 Comments

I don't see that the function names are/can be copyright, but I am not a lawyer and this is not legal advice. I would question the benefits to doing this though: there are more disadvantages than advantages to using the same name as inbuilt functions. Your function is unique, so why not give it a unique name?
For a longer discussion on this topic:
I'm not a lawyer either.
There is one aspect different here: Boris Blagovs function is aimed at having the exact same functionality. The other reasons for choosing your own name still apply, so in sum total I would still suggest you pick your own name. In some of my functions I use my own extension of regexp to provide backward compatibility. Using your own function name will help in such cases as well.
If the functions are intended to have the same functionality as Mathworks functions, then distribution rights requires careful reading of the Mathworks license, which in at least some circumstances specifically do not permit that. And that applies even if you do not use the same function names.
Thank you all for your input.
@Stephen, I read the topic and answers but I don't see how it relates to the copyright question, am I missing something? I am leaving aside potential coding issues.
@Rik and @Walter, this is what I was thinking about. However, I am wondering where do you draw the line. I mean, all software packages for computing come with some form of exp() or log(), so I feel it is a specific question with no real answer. This thought is also with respect to what @Jan and @Image Analyst are saying. Names should not be, as there are generic functions but then it is about what specific functions do.
The thread Stephen linked did not apply to the copyright question, but to the intention of using the same name. Can you absolutely guarantee that your function will behave the same, in every possible edge case? Your function is your function. With it's own name, it's easier to take credit for it, easier to find, and easier to spot for users that it might not have the same result as the builtin, especially for edge cases.

In about 15 years of being active member of online forums I have always wondered why, without any exception, in every forum thread with a question (irrespective of type of forum) people start telling the person asking a question "this question means that you are doing X, you should be doing Y", even when it is explicitly stated that this is understood.

This is a phenomen that I call "the global variable problem". Using global variables is in general bad practice, suboptimal and there are probably thousands of reasons why it should be avoided, yet every single possible thread about somebody doing something with gvars is about how bad this is and only occasionally there are practical answers (this is not the case in this thread, but the evidence stands). If it should not be done it should not be included as a feature in the first place. I don't use them, I don't defend and I don't like them but at some point the bashing is enough.

I also understand that you do not have the context of why I might want/need to do something like this, hence you give the general advice which is "that you are suggesting is bad practice". I know that without context you might not see reasons why someone would do such a thing on purpose (sometimes even with context). I think the context is complex and it is well beyond the scope of the question, therefore I decieded to simply put a statment that this is not the point of the question.

I know that you are taking from your own time to respond to this in order to help me write a better code, and I appreciate this but please understand that there is context around the problem and I am not asking whether something should ro should not be done.

If you are deliberately doing it so that someone can avoid purchasing a toolbox, then it is not permitted by the Mathworks license.
Writing routines with similar names to Mathworks functions but which extend functionality by operating on a different class of data is permitted. For example writing a mvrnd() that operates over a field of Gaussian rationals would be permitted.
Exactly because this is about functions that have to do with a tooblox I am wondering whether it is allowed to use their names. This is not about people avoiding the toolbox but it crosses into the domain where it is not simply rewriting a generic function like "log" or "exp" where every other langauge has them.
I am not even sure if your suggestion (extending a function) is permitted. The closest I can find to this in the agreement is:
" Licensee shall not [...] permit any other individual or entity to:
3.4. adapt, translate, copy, convert, use, test, benchmark, or determine
the expression or design of, a Program or any materials derived from or
generated by a Program, in order to make or distribute an application or
software, a principal purpose of which, as reasonably determined by
MathWorks, is to perform the same or similar functions as a Program or
other MathWorks product or service or which replaces any component of a
Program or other MathWorks product or service. Licensee shall not use a
Program to compete with the products or businesses of MathWorks, including
by distributing libraries or any form of an entire Program or Program
Component;"
If you write a mvnrnd that extends to Gaussian rationals, according to the section you are still not allowed to distribute it if it has also the normal functionality of mvnrnd().
So I feel it is a gray area and therefore I made the thread. These texts are so vague (on purpose) that it is hard to get a sense of where the bounds are. For example, according to 3.4., I am not sure that you are allowed at all to write functions (arbitrarily named) that perform anything similar to other Matlab functions at all, since "reasonably determined by MathWorks" they achieve the same goal. In the extreme - drawing from the multivariate normal distribution (absurd example but theoretically valid). And I can't buy an argument 'Mathworks knows but doesn't do anything about it, so it must be legal', because one does not lead to the other.
The main reason you get answers related to whether or not it is a good idea to do it or not is that you are asking a question on a general Matlab forum that cannot possibly be answered by a general Matlab Answers visitor. If you want an answer that carries legal weight you have to ask a lawyer or ask Mathworks directly. Even on the off-chance that a lawyer who happens to be well versed in this exact part of the law happens to also work with Matlab and be browsing the forums would you trust their word that they are in fact a person with such knowledge just because they say so?!
So yes, threads like this will often end up as a hazy general discussion on why you probably wouldn't want to do it and all the various pros and cons.
If a staff member says that it is forbidden, I would trust them just because they said so, yes. Most probably they would point me to the correct paragraph of the agreemnet as well. I have not read the whole agreement in full, I did check the license (parts of it) and the program offering guide but I might have simply missed it.
Besides, I think there were some really good remarks and the post from Guillaume is really spot-on. Others have also given me ideas and shared their experience with similar situations and dealing with toolboxes. So I am happy and thankful for the help that I got. You could take away the "hazy" stuff and still have a lot of substance. For me at least.
Mathworks does not permit its staff to give public interpretations of the license terms, except in the form of occasional "Solutions" posted under the Mathworks Support account. The correct avenue is to contact either Technical Support or Sales with specific scenarios.
Actual lawyers not working for Mathworks do not comment on these kinds of situations without a lot of talk about jurisdiction -- and talk about the difference between what the law says and what the case law is in that particular jurisdiction.

Sign in to comment.

 Accepted Answer

Something that has not been touched on: while the name of a function is not copyrightable, the function API (function name + inputs and outputs) might be depending on your jurisdiction. As far as I know (I am not a lawyer), it's not copyrightable in the EU, but in the US the latest ruling is that they are (after an earlier ruling that they weren't).
This is very relevant for you as you are not just replicating a function name but the whole signature (if you are replicating a toolbox function).

1 Comment

Now that's something highly relevant. Thank you.
The more I read about this the more muddy the picture is. I think it's best not to do this just to be safe (leaving all the coding issues aside). Even though I am in the EU.

Sign in to comment.

More Answers (4)

There have been reports in this forum about cases, in which using the name of a toolbox function without having a license for this toolbox, caused an error during the folder is included in the path - before the function is used. So beside the legal issues, there could be a restriction in the software.
I've shared a larger program with another lab, which did not have the Signal Processing Toolbox. It was used in my code only for a Butterworth filter. I've rewritten a function to calculate the filter parameters from scratch without taking a look into the original function to be sure. Now I'm using this workaround:
function vargargout = myButter(varargin)
persisent butterFcn
if isempty(butterFcn)
if ~isempty(which('butter.m'))
butterFcn = @butter;
else
butterFcn = @local_butter;
end
end
[varargout{1:nargout}] = butterfcn(varargin{:});
end
function [Z, P, G] = local_butter(n, W, pass)
...
end
Now Matlab's version is used, if it is available, and my one otherwise. This does not compete with Matlab's Signal Processing Toolbox. But if I write replacements of all functions of this toolbox and offer it commercially, I'd expect troubles.

1 Comment

Yes, I do this all the time. I am forced to use two computers to work on a code, one has no toolboxes at all, so I have a "switch" at the top of the code, that calls "free to use" functions with the same functionality if I am on computer 1 and use the toolbox if I am on computer 2.
However, reading the License agreement carefully I am not even sure this is allowed officially. I know it sounds absurd and I wouldn't expect troubles in general, but technically speaking, these functions (not written by me, having different syntax and all) are theoretically competing with the toolboxes that I have on one of the computers. Exaclty as in your example above.

Sign in to comment.

The names of the function are not covered by a copy right. Of course, they are not: imagine the built-in functions "i" and "j".
But it will be a bad idea to call your function like built-in functions of Matlab's toolboxes. Shadowing the built-in functions can cause serious troubles. After an experiment with a user-defined and buggy version of strcmp, my Matlab installation could not be used anymore: There was no chance to modify the path or to open the file for editing. I had to use an external editor to fix this.
It is very hard to guarantee that there are no collisions between user-defined and Matlab's functions. If you do not own all toolboxes or future versions of Matlab contain new functions, there is no chance to check this. You can use FEX: UniqueFuncNames to check at least the locally defined functions.

4 Comments

That is what I was thinking as well, functions like exp() or log() cannot be copyrighted but I am wondering whether a line can be drawn once we start using names from toolboxes with specific functionality. I couldn't find a list of what is copyrighted, so that I can see if function names are missing from that list. The code within functions themselves is however clearly copyrighted.
"It is very hard to guarantee that there are no collisions between user-defined and Matlab's functions." - This is unavoidable. It has happend to me at least twice where I have written a function and in the next release (or several releases later) Mathworks adds a function with that name and my code breaks without me understanding at first why. This is simply a fact of life.
@Boris: If MathWorks has published a function, whose name you used before, did you accuse them to break your copy right? Of course not. But if they copied the source from your function, this would be a problem.
Some years ago I've improved the processing speed of the toolbox function filtfilt.m by modifying some lines of code. I did not publish the patched function, but a tool to modify the existing file on the machine of the user. I asked MathWorks, if this is a conflict with the Terms of Use, paragraph 2. iii:
Content that you submit must not directly compete with products
offered by MathWorks.
Is improving the same as competing? The MathWorks accepted my code. The new version of filtfilt uses equivalent methods now.
So if you want a really trustworthy answer, contact MathWorks directly.
That is interesting case, thanks for sharing!
I do see why they accepted that - you have done an extention to their product and you did not include their original code. Essentially, you did some optimizing work for them for free without breaching any rules. This is obviously improving and not competing. The idea with the tool is quite elegant solution, I might see if I can adapt that to my situation.
P.S. my main hope was that a staff member might pitch in, especially if it is clearly forbidden.
P.S.S. Regarding your question, I am unsure it is applicable, as I have not copyrighted the function. However, theoretically, if I had any grounds to copyright it/patent it (i.e. a patent body accepted that), then their copying would be copyright infringing if it has the same functionality and name, yes.
Boris, you mentioned that you are in the EU. The entire EU has signed copyright treaties such that "sufficiently original" works are automatically copyrighted at the moment of creation, without any need to register the copyright. Registering the copyright might extend the legal protections available (depending on jurisdiction), but in any jurisdiction that has signed the treaties, the item is copyrighted upon creation even without registration.

Sign in to comment.

The names are not copyrighted. I even know of some functions, skewness() and dataset(), that are being sold by a commercial company. Mathworks knows about that situation. There's no problem, other than being the MAJOR problem that you "put aside".

1 Comment

Yes, I think the same, there are many generic functions names. But when it comes to toolboxes I feel it becomes more blurry. Hence the question. Thank you for your time, though!

Sign in to comment.

I am not a lawyer. But I would argue that it is the code that matters, and the code that has a copyright, which will reside in that code. The name of the function is not covered though. It cannot be. If anything, the name of a function might involve a question of trademark. But that is not the case. You will not find trademarks on the names of functions.
So you can distribute your own version of mvnrnd. It is arguably a poor idea, since your version of that code may well not be coded as well. And if it has subtly different functionality than the one that is supplied by MathWorks then you may be creating subtle bugs inside the code of those who use MATLAB and who have been given your code, possibly without knowing what was done. Such a bug could be difficult to track down.

1 Comment

I agree with you about arguing that the code matters and that would be my defense as well, but as you I am also not a lawyer. I am hoping I can find some factual evidence. Thank you for your time, though!

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!