MATLAB 帮助中心
代码注释、转换设定符
%
百分比符号 (%) 表示程序主体中的不可执行的文本,一些函数还将百分比符号解释为转换设定符。例如,% Code comment 使用百分比符号表示程序中的不可执行的文本注释。
% Code comment
示例
全部展开
在代码行中使用 % 符号添加代码注释。该行上 % 符号后出现的任何文本都是不可执行的。
a = [1 2 3]; % This line is a code comment, and you can % extend comments to multiple lines. b = a.^2;
使用 sprintf 函数用输入值替换字符串和十进制数字。sprintf 函数将百分比符号解释为转换设定符。
sprintf
A = 1; sprintf("%s = %d","Index",A)
ans = "Index = 1"
在 R2006a 之前推出
%{ %}
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处