How to prevent matlab from exponential form in displaying arrays

16 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by