How do you get a specific decimal accuracy with the fprintf function?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ashlianne Sharma
el 20 de Abr. de 2021
Comentada: Ashlianne Sharma
el 20 de Abr. de 2021
I want to display my r variable with 6 decimals, but I am not sure how to format the line. I could not really find how to with the documentation page and would appreciate some guidance, Thank you so much!!
fprintf("The estimated principle stress val is %6f .\n " + r )
Respuesta aceptada
the cyclist
el 20 de Abr. de 2021
Editada: the cyclist
el 20 de Abr. de 2021
Your r variable needs to be a second argument (not using a plus sign as you did).
r = pi;
fprintf("The estimated principle stress val is %9.6f.\n ",r)
The %9.6f indicates that the output should use 6 decimal places, and field width of 9.
Más respuestas (0)
Ver también
Categorías
Más información sobre Stress and Strain en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!