# MATLAB如何为程序或自定义函数添加帮助说明 | 为你的程序或自定义函数添加帮助说明

## MATLAB如何添加帮助说明

### 2. 撰写帮助说明

#### 2.1 内容一：简要说明

function ...
%POW2 Base 2 power and scale floating point number
...
end


#### 2.2 内容二：使用方式和语法（syntax）

function ...
%POW2 Base 2 power and scale floating point number
%    X = POW2(Y) for each element of Y is 2 raised to the power Y.
%
%    X = POW2(F,E) for each element of the real array F and a integer
%    array E computes X = F .* (2 .^ E).  The result is computed ...
...
end


#### 2.3 内容三：扩展阅读

...
%
...


%   For more information, see <a href=
%   "https://blog.csdn.net/Undefinedefity">my CSDN blogs</a>.


### 3. 为普通程序文件添加帮助说明

%TEST This is a sample test program to tell you how to write a help
%description
%   This paragrah should be the details of this matlab file
%   This paragrah should be the details of this matlab file
%   This paragrah should be the details of this matlab file
%   This paragrah should be the details of this matlab file
%
%
%   "https://blog.csdn.net/Undefinedefity">my CSDN blogs</a>.


### 4. 我的一个函数示例

function [R] = rot(axis, angle, homo)
%ROT   Returns a rotational matrix about a specific basic axis
%   R = ROT(axis, angle, 'homo')
%
%   axis = 'x', 'y', or 'z'.
%   angle should be in radian.
%   'homo' is optional if you want an homogenouse form else you do not need
%
%   "https://petercorke.com/toolboxes/robotics-toolbox/">The
%Robotics Toolbox for MATLAB (RTB) by Peter Corke</a>.

%   Version:            1.1
%   Author:             Def Li
%   Contact:            def460511281@163.com

ct = cos(angle);
st = sin(angle);

if nargin >3
error('The number of input arguments should not be more than 3!');

elseif nargin == 3 && strcmp(homo, 'homo') % homogenouse form
if (axis == 'x')
R = [
1   0     0    0
0   ct   -st   0
0   st    ct   0
0   0     0    1
];

elseif (axis == 'y')
R = [
ct   0   st   0
0    1   0    0
-st   0   ct   0
0    0   0    1
];

elseif (axis == 'z')
R = [
ct   -st   0   0
st    ct   0   0
0     0    1   0
0     0    0   1
];
else

end

elseif nargin ==2
if (axis == 'x')
R = [
1   0     0
0   ct   -st
0   st    ct
];

elseif (axis == 'y')
R = [
ct   0   st
0    1   0
-st   0   ct
];

elseif (axis == 'z')
R = [
ct   -st   0
st    ct   0
0     0    1
];
else

end

else

end

end


### 5. 参考

[2] qnczmf, Matlab路径设置（3种方法）https://blog.csdn.net/u012991043/article/details/84836971

[3] 桂哥317, 如何规范地编写一个MATLAB函数文件: https://blog.csdn.net/qq_15971883/article/details/82884353

• 6
点赞
• 16
收藏
觉得还不错? 一键收藏
• 0
评论
03-30
10-11
06-27 6397
02-22 4783
05-24 4万+
01-08 629
02-28 894
08-15 996

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。