How can I display a number with only two digits after the decimal point in MATLAB?
Mostrar comentarios más antiguos
I would like to display a number with only two digits after the decimal point in MATLAB.
2 comentarios
Jan
el 3 de Mzo. de 2011
What is the relation to the tag "digital signal processing"? Can you explain any details concerning the question, please?
Mardhika Jenned
el 3 de Mzo. de 2011
Respuesta aceptada
Más respuestas (4)
masoud sistaninejad
el 30 de Dic. de 2020
4 votos
format shortg
y = 3.3333333333333333333333333333333333333
y_out = round(y,2)
Mardhika Jenned
el 3 de Mzo. de 2011
0 votos
Mardhika Jenned
el 3 de Mzo. de 2011
0 votos
1 comentario
Walter Roberson
el 3 de Mzo. de 2011
ceil(10/3)
For the specific case of 2 decimal places (does not work for any other number)
format bank
10/3
4 comentarios
Omar Lakkis
el 15 de Sept. de 2021
Thanks. I'm teaching a financial computing course and was looking for banker's output :-)
Walter Roberson
el 15 de Sept. de 2021
Be careful about rounding vs truncation. I do not know what is standard for banking purposes.
Megha
el 16 de Sept. de 2021
in the same scenario, could you please tell how to obtain 03.33??
x = 10/3;
sprintf('%05.2f', x)
compose("%05.2f", x)
num2str(x, '%05.2f')
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!