Exact number of digits output in num2str
Mostrar comentarios más antiguos
I am building input files for Nastran and it requires exact spacing in the strings for the numbers (in string format). I am doing a lot of runs so I don't want to change my Matlab code all the time. I need to output some values with exactly 4 characters (so 1 becomes 1.00, pi becomes 3.14, 0.5 becomes 0.50, etc), but I haven't been able to figure it out yet. Using the minimum number of characters in num2str with '%2f' and rounding beforehand using round(100*n)/100 yields for pi 3.140000, probably due to roundoff error. Any help?
Respuesta aceptada
Más respuestas (1)
Bob Roos
el 23 de Jun. de 2015
0 votos
Categorías
Más información sobre Numeric Types en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!