필터 지우기
필터 지우기

Data representation of Integer values in .mat file

조회 수: 1 (최근 30일)
SatyaPrakash Gupta
SatyaPrakash Gupta 2020년 6월 12일
댓글: SatyaPrakash Gupta 2020년 6월 15일
Hello ,
I have attached mat file which has one table with x,y,polylinetype ..etc
In Table "y" , i could see the row number 9 has whole number i.e instead of 3787 on 3.7870e+3 but rest of the data are represented as 1.3e+3
how can i represent all the data in syn form i.e 1.23e+3 ?

채택된 답변

Walter Roberson
Walter Roberson 2020년 6월 12일
Use the format command with any of the options
  • short
  • long
  • shorte
  • longe
All of these will represent the values that happen to be exact integers, in the same form as the other numbers.
However, none of these will be similar to 1.23e+3 with one leading decimal place, then the '.', then two digits, then exponent. If you want something like that, you need to do the equivalent of
fprintf('%.2e\n',matfile.y)
By the way, you can see by
>> num2hex(matfile.y(8:10))
ans =
3×8 char array
'456ceeaf'
'456cb000'
'456c5502'
that y(9), the middle of those lines, is being represented by the same data format as the other numbers.

추가 답변 (1개)

Robin Kirsch
Robin Kirsch 2020년 6월 12일
Use the format operator found here
>> format shortEng
>> 3787
ans =
3.7870e+003
  댓글 수: 7
Walter Roberson
Walter Roberson 2020년 6월 15일
You need %.16e to avoid data loss
SatyaPrakash Gupta
SatyaPrakash Gupta 2020년 6월 15일
Many many Thanks Walter Roberson :-)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by