How to prevent matlab from exponential form in displaying arrays

조회 수: 6 (최근 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 CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by