为什么 MATLAB 不能绘制单词 "factory"?
Why can't MATLAB plot the word "factory"?
考虑以下 MATLAB 代码:
text(0, 0, 'factory');
xlim([-1, 1]);
ylim([-1, 1]);
预期目标是在其中包含单词 "factory" 的图形。没有字出现。现在将单词 "factory" 替换为任何其他单词,上面的代码将按预期工作。这已通过 MATLAB 2017b 和 2015b
测试
有人知道这是怎么回事吗?
问题解释
根据 MATLAB title function documentation:
The words default, factory, and remove are reserved words that
will not appear in a title when quoted as a normal character vector.
To display any of these words individually, precede them with a
backslash, such as '\default' or '\remove'.
这个逻辑同样适用于文本函数。 Default Property Values 页面提供了有关 factory 关键字的作用以及我们不能将其用作图形函数参数的原因的更多详细信息。
解决方案
以下代码工作正常:
text(0, 0, '\factory');
xlim([-1, 1]);
ylim([-1, 1]);
考虑以下 MATLAB 代码:
text(0, 0, 'factory');
xlim([-1, 1]);
ylim([-1, 1]);
预期目标是在其中包含单词 "factory" 的图形。没有字出现。现在将单词 "factory" 替换为任何其他单词,上面的代码将按预期工作。这已通过 MATLAB 2017b 和 2015b
测试有人知道这是怎么回事吗?
问题解释
根据 MATLAB title function documentation:
The words default, factory, and remove are reserved words that will not appear in a title when quoted as a normal character vector. To display any of these words individually, precede them with a backslash, such as '\default' or '\remove'.
这个逻辑同样适用于文本函数。 Default Property Values 页面提供了有关 factory 关键字的作用以及我们不能将其用作图形函数参数的原因的更多详细信息。
解决方案
以下代码工作正常:
text(0, 0, '\factory');
xlim([-1, 1]);
ylim([-1, 1]);