How to format matrix to 4 decimal places in engineering notation:
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have calculated this matrix:
[ 206043.95604395602131262421607971, 0, -206043.95604395602131262421607971, 82417.582417582406196743249893188, 0, -82417.582417582406196743249893188]
[ 0, 72115.384615384603966958820819855, 96153.84615384613862261176109314, -72115.384615384603966958820819855, -96153.84615384613862261176109314, 0]
[ -206043.95604395602131262421607971, 96153.84615384613862261176109314, 334249.08424908420614277323087056, -178571.42857142854481935501098633, -128205.12820512818483014901479085, 82417.582417582406196743249893188]
[ 82417.582417582406196743249893188, -72115.384615384603966958820819855, -178571.42857142854481935501098633, 438415.75091575086407829076051712, 96153.84615384613862261176109314, -366300.36630036626011133193969727]
[ 0, -96153.84615384613862261176109314, -128205.12820512818483014901479085, 96153.84615384613862261176109314, 128205.12820512818483014901479085, 0]
[ -82417.582417582406196743249893188, 0, 82417.582417582406196743249893188, -366300.36630036626011133193969727, 0, 366300.36630036626011133193969727]
Which is obviously very messy. Is there a way I can output it in 4 significant figures in engineering notation, ie for the first entry, 206.0e3?I have tried using the format command, but cannot get it to work, and vpa got me to have it in decimil form, but is very long. Thanks.
0 comentarios
Respuestas (2)
Steven Lord
el 4 de Nov. de 2020
Since vpa worked on this array, it's most likely a symbolic array. If so call vpa with two inputs, the first this array and the second the number of digits you want to use to display the array.
Alternately convert this array (since it contains no symbolic variables) to a double precision array using double then it will respond to the format command.
0 comentarios
Michael Croucher
el 3 de Nov. de 2020
Editada: Michael Croucher
el 3 de Nov. de 2020
There are only a limited number of supported formats that apply automatically to all output. The closest to what you want is shortEng:
format shortEng
Entering
[ 206043.95604395602131262421607971, 0, -206043.95604395602131262421607971, 82417.582417582406196743249893188, 0, -82417.582417582406196743249893188]
will give
ans =
206.0440e+003 0.0000e+000 -206.0440e+003 82.4176e+003 0.0000e+000
but that's not quite what you want because of the precision shown.
0 comentarios
Ver también
Categorías
Más información sobre Matrices and Arrays 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!