Best practice to add license text to matlab code.
3 views (last 30 days)
Show older comments
Hi!
I have been working on some Matlab code recently and I would like to publish it under some open source license. If I were programming in C, I would just add the license text as a comment at top of each file. However, Matlab considers the first comment to be the documentation. Thus, I can't really put it there because nobody will be able to lookup what the function does. In GNU/Octave I could do this, because it ignores the first comment if it starts with the word "Copyright". So my question is: What's the best way to add an open source license text to Matlab code? Should I put it below the help comment? If I remember correctly, it is, at least for the GPL, recommended to put the notice on top of each file. Or should I place it in a separate file exclusively and not in each individual m-file?
Thanks for your suggestions, Laurent
0 Comments
Accepted Answer
Jan
on 31 May 2011
You can insert a comment after the initial help block separated by an empty line:
function Output = FuncName(Input)
% FuncName - H1 line: Single line description
% Now the exhaustive help text
% descibing inputs, processing and outputs
%
% Author, Date
%
% See also SIN, COS, TheOtherFunction.
% Copyright: This is published under BSD ...
% Do not, but you are allowed to, as long as...
disp('Running the function FuncName');
...
The H1 line supports LOOKFOR, the HELP command shows the initial comment block until the first non-comment line, e.g. a blank line. The "See also" line appears as hyperlinks automatically.
By this way the license comment block is seen only, if the file is opened in the editor. This is the style used for Matlab's toolbox functions, see e.g. FILTFILT.
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!