我需要将文本添加到我需要为我的任务建模的自由人体图中,但我的教授期望我这样做的方式不起作用,所以我想知道我该如何做到这一点
这是我为我的任务编写的代码
%work assignment 2
annotation("rectangle",[.1 .2 .5 .4]);
annotation("line",[.6 .8],[.4 .4]);
annotation("textarrow",[.6 .8],[.4 .55]);
'string';
('F=mg');
annotation("textarrow",[.35 .35],[.45 .8]);
annotation("textarrow",[.35 .35],[.4 .1]);
现在我需要在箭头末尾添加标签,根据任务 pdf,我应该使用字符串来添加文本,但这似乎确实做了任何事情,所以我想知道我该怎么做。我也不太擅长 matlab,所以如果你们能告诉我在哪里更改代码,我将不胜感激。
这是输出,字符串位中的 f=mg 应该位于斜线上,其他 2 个箭头也需要文本:
这不是有效的 MATLAB 语法,虽然它不会产生错误,但第二行和第三行基本上什么也不做:
annotation("textarrow",[.6 .8],[.4 .55]);
'string';
('F=mg');
String
名称-值对应位于对 annotation
调用的括号内,因为它们是该函数的输入。
annotation("textarrow",[.6 .8],[.4 .55], 'string', 'F=mg');
如果您想将其拆分为多行,则需要
...
来继续行
annotation("textarrow",[.6 .8],[.4 .55], ...
'string', 'F=mg');
文档参考:https://uk.mathworks.com/help/matlab/ref/matlab.graphics.shape.textarrow-properties.html