How to prevent matlab from exponential form in displaying arrays

7 Ansichten (letzte 30 Tage)
Leos Pohl
Leos Pohl am 22 Jun. 2021
Bearbeitet: dpb am 23 Jun. 2021
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?

Akzeptierte Antwort

dpb
dpb am 22 Jun. 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 Kommentare
Leos Pohl
Leos Pohl am 23 Jun. 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 am 23 Jun. 2021
Bearbeitet: dpb am 23 Jun. 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
>>

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Fortran with MATLAB finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by