How to format scientific notation to have the same power?

21 visualizaciones (últimos 30 días)
I know this might be dumb but it is messing me up so much. I have a table with data that is in scientific notation. I would like for all the numbers to be displayed to the same power of 10^-10. for example instead of 1.5e-9 , I would like it to be displayed as 15e-10.
MATLAB Script
----------------------------------------------------------------------------------------------------
clear; clc;
x=[702.8530e-012; 1.1511e-009; 1.0467e-009; 1.3369e-009; 723.8877e-012; 748.1630e-012; 1.0198e-009; 1.1897e-009]
number=[ 1; 2; 3; 4; 5; 6; 7; 8]
T=table(number,x)
------------------------------------------------------------------------------------------------------
I would like for all those e-9 to be e-10, does not matter if some numbers have more digits or significant figures than others, the only thing that I am looking for is that 10^-10 format.
if anyone can help, I appreciate it a lot!

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Dic. de 2021
table() objects do not support that customization. You would need to switch the items to text
  2 comentarios
Alfredo Scigliani
Alfredo Scigliani el 7 de Dic. de 2021
Oh I see, what would be a possible way then? Maybe if it was a 8x2 matrix instead of a table? If possible, how can that customization should be done?
Walter Roberson
Walter Roberson el 7 de Dic. de 2021
x=[702.8530e-012; 1.1511e-009; 1.0467e-009; 1.3369e-009; 723.8877e-012; 748.1630e-012; 1.0198e-009; 1.1897e-009]
x = 8×1
1.0e+-8 * 0.0703 0.1151 0.1047 0.1337 0.0724 0.0748 0.1020 0.1190
number=[ 1; 2; 3; 4; 5; 6; 7; 8]
number = 8×1
1 2 3 4 5 6 7 8
T=table(number,x)
T = 8×2 table
number x ______ __________ 1 7.0285e-10 2 1.1511e-09 3 1.0467e-09 4 1.3369e-09 5 7.2389e-10 6 7.4816e-10 7 1.0198e-09 8 1.1897e-09
T.x = compose("%8.4f", T.x/1e-10) + "E-10"
T = 8×2 table
number x ______ ______________ 1 " 7.0285E-10" 2 " 11.5110E-10" 3 " 10.4670E-10" 4 " 13.3690E-10" 5 " 7.2389E-10" 6 " 7.4816E-10" 7 " 10.1980E-10" 8 " 11.8970E-10"
The "8" part of the %8.4f might need to be adjusted if you had values that were higher scale relative to 1e-10 . Also note that values smaller than 1e-16 will show up as 0

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by