Formatting floating and integer signed numbers

2 visualizaciones (últimos 30 días)
Saikat Banerjee
Saikat Banerjee el 12 de Jun. de 2020
Comentada: Saikat Banerjee el 12 de Jun. de 2020
Suppose a=5 and b=-6. If I use sprintf and write sprintf("℅0.2f+℅0.2f°,a,b) we get 5.00+-6.00 as answer and not 5.00-6.00. I would like to display the answer as 5.00-6.00. How to do it?

Respuesta aceptada

James Tursa
James Tursa el 12 de Jun. de 2020
Editada: James Tursa el 12 de Jun. de 2020
sprintf("%0.2f%+0.2f",a,b)
Having the + inside the %format stuff forces the sign to print.

Más respuestas (0)

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by