在官方文档中尝试这个其他部分。更彻底MATLAB>用户指南>桌面工具与开发环境>自定义帮助和演示>提供您自己的帮助和演示。这描述了简单的helptext和生成单独的HTML帮助文件。
这是我接受的helptext格式,发现有用。
function foo(x,y,z)
%FOO One-line description goes here
%
% foo(x,y,z)
%
% Multi-line paragraphs of descriptive text go here. It's fine for them to
% span lines. It's treated as preformatted text; help() and doc() will not
% re-wrap lines. In the editor, you can highlight paragraphs, right-click,
% and choose "Wrap selected comments" to re-flow the text.
%
% More detailed help is in the extended help.
% It's broken out like this so you can keep the main "help foo" text on
% a single screen, and then break out obscure parts to separate sections.
%
% Examples:
% foo(1,2,3)
%
% See also:
% BAR
% SOMECLASS/SOMEMETHOD
disp(x+y+z);
function extended_help
%EXTENDED_HELP Some additional technical details and examples
%
% Here is where you would put additional examples, technical discussions,
% documentation on obscure features and options, and so on.
error('This is a placeholder function just for helptext');
>函数签名后的第一行称为“H1行”。它需要只是一行,所以它被内容rpt()正确地拾取,它可以从你的函数中的helptext自动生成一个Contents.m文件
> H1行中的函数名称都是大写,不管签名中函数名称的实际大小写
>案例涉及“另见”。我不知道哪一个案例都行事;这个确实是这样的。
>“参见:”之后的函数名称都是大写。方法名称合格;我认为与当前方法在同一类中的方法的名称可以是不合格的。
H1线和“示例:”之间的所有内容只是一种常见的格式化,我发现可读性; help()不特别对待。
您可以在帮助中使用有限形式的超链接。特别是,您可以使用超链接来调用任意的Matlab命令,并通过调用help()来指向helptext的其他部分。您可以使用它来指向任何功能; “function> subfunction”只是用于在help()调用中寻址子函数的语法。不幸的是,由于您需要将这些超链接中的“帮助”或“doc”放在一个或另一个表示形式中。如果有直接的helptext超链接形式会更好。