format numbers in plot

3 次查看(过去 30 天)
hi
i am using text command to show variable value in plot
but i am not able to format this variable (format short)
text(5,3,['variable value=',char(a)]) i get variable value = 0.324546494654894846156486494646
so how to format it to 0.32454

采纳的回答

Daniel Shub
Daniel Shub 2012-4-25
instead of your char(a)
I would use
num2str(double(a), 6)
or
sprintf('%0.6f', double(a))
  3 个评论
Daniel Shub
Daniel Shub 2012-4-25
See my edit. I missed your "a" was a sym. You need to convert the sym to a double first.
Haris Hameed
Haris Hameed 2012-4-25
thankx it works

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numbers and Precision 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by