"text" Function Does Not Accept Inputs of Type Single.

8 次查看(过去 30 天)
The function "text" does not accept inputs of type single. Is there any existing workaround?
The follow code block produces an error when passing variables of type single as input into the "text" function.
figure()
axes()
xlim([0 10])
ylim([0 10])
text(single(5), single(5), "My String");
Error using text
First two or three arguments must be numeric doubles.

采纳的回答

MathWorks Support Team
One possible workaround is to cast the variables of type single into type double. The "Position" name-value pair can also be used to specify variables of type single as the x and y coordinates of the text position. Below is a brief snippet demonstrating this workaround.
figure()
axes()
xlim([0 10])
ylim([0 10])
text('Position', [single(5), single(5)],'String', 'My String');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by