Best practice to add license text to matlab code.
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Jan
2011-5-31
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!