matlab中uint8代码?

2023/8/2补充发现这个知乎的答主的规范很好,记录一下:科研小技巧——MATLAB的编码规范 - 西涯先生的文章 - 知乎在编写代码的时候,越发觉得一个好的代码需要良好的可读性,在github上看到了别人的代码,写得很规整,觉得很有启发,总结一下。函数:在前面说清楚函数的作用,输入输出的接口含义,例如function g = func(k)
% func creates a relationship betwween angle and transformation matrices (formed by vector)
%
%
EXAMPLE
%
g = func(k)
%
creates a relationship betwween g and k
%
%
INPUT: input parameters
%
k (nx1): curve angle
%
%
OUTPUT:
output parameters
%
g (n,16):
curve with n 4x4 transformation matrices reshaped into nxn vector (columnwise)
%
%
Author: xxx
%
Date: 2022/02/16
%
Version: 0.1
在前面写清楚每个变量的大小和参数类型以及含义arguments
k(1,:) double %curve angle
end
另外可选参数也可以用arguments很方便的定义:比如函数中有option选项,function [fig] = draw_ctcr(g,tube_end,r_tube,options)
在arguments定义option,可以定义默认值:在后面进行option的判断调用函数直接调用。大的版块用两个百分号注释,大板块下的小模块用一个百分号注释。比如这样暂时想到这些,有其他的再记录吧。

我要回帖

更多关于 matlab中uint8 的文章

 

随机推荐