How to prevent matlab from exponential form in displaying arrays

7 visualizzazioni (ultimi 30 giorni)
When I print some array, matlab prints:
ans =
1.0e-14 *
0.1
0.2
...
Is there any way to prevent the initial 1.0e-14 * and apply it to each term in the array?

Risposta accettata

dpb
dpb il 22 Giu 2021
With the common disp() or echo of a variable to the command window, no--a MATLAB array is an entity.
You can output in whatever format you wish explicitly, however...
fprintf('%#9.0G\n',x)
although it will print in normalized range with the n.nE-ee instead of with the scale factor and leading 0. as does the command window display. Why they did that I don't precisely know/understand but there's not an easy precision scale factor in C as with Fortran FORMAT so to mimic the display exactly takes some additional steps.
  2 Commenti
Leos Pohl
Leos Pohl il 23 Giu 2021
I am more interested, whyn i type x in the command window, I want to see the full number, not that exponential shortened version. This is quite frustrating, especially, when i need to compare it to some other precise value.
dpb
dpb il 23 Giu 2021
Modificato: dpb il 23 Giu 2021
Oh.
>> x=[1:2]*1E-15;x=x.'
x =
1.0e-14 *
0.100000000000000
0.200000000000000
>> format longe,format compact
>> x
x =
1.000000000000000e-15
2.000000000000000e-15
>> x(1)=x(1)*1E30
x =
1.000000000000000e+15
2.000000000000000e-15
>>

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Fortran with MATLAB in Help Center e File Exchange

Tag

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by