How to prevent matlab from exponential form in displaying arrays

8 ビュー (過去 30 日間)
Leos Pohl
Leos Pohl 2021 年 6 月 22 日
編集済み: dpb 2021 年 6 月 23 日
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?

採用された回答

dpb
dpb 2021 年 6 月 22 日
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 件のコメント
Leos Pohl
Leos Pohl 2021 年 6 月 23 日
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 2021 年 6 月 23 日
編集済み: dpb 2021 年 6 月 23 日
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
>>

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFortran with MATLAB についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by