format numbers in plot

2 visualizaciones (últimos 30 días)
Haris Hameed
Haris Hameed el 25 de Abr. de 2012
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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numbers and Precision en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by