Stuck in exponential notation format
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Oliver
el 31 de En. de 2023
Comentada: Oliver
el 31 de En. de 2023
Hello All,
I am struggling to display my answer without scientific notation.
fprintf('Failed due to temperature %0.1d\n',Percentfailtemp)
This will spit out scientific notation in the command window, regardless of the fact that the value of my variable within the workspace is not in scientific notation.
Is there a work around?
Thanks in advance
0 comentarios
Respuesta aceptada
Walter Roberson
el 31 de En. de 2023
format long g
for Percentfailtemp = [0.011 0.11 1.1 11 110 110.234 100*(1-eps)]
fprintf('Failed due to temperature %0.1d\n',Percentfailtemp)
end
Scientific notation got used precisely in the situations where the input is not an integer. This includes cases such as
100*(1-eps)
That display as integers but are not exactly integers.
Do not use a %d format for values that are not exact integers. If you want to use 1 decimal place, use a %f format
for Percentfailtemp = [0.011 0.11 1.1 11 110 110.234 100*(1-eps)]
fprintf('Failed due to temperature %0.1f\n',Percentfailtemp)
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!