MATLAB Answers

Data representation of Integer values in .mat file

2 views (last 30 days)
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 ?


Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 12 Jun 2020
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
By the way, you can see by
>> num2hex(matfile.y(8:10))
ans =
3×8 char array
that y(9), the middle of those lines, is being represented by the same data format as the other numbers.


Sign in to comment.

More Answers (1)

Robin Kirsch
Robin Kirsch on 12 Jun 2020
Use the format operator found here
>> format shortEng
>> 3787
ans =


Show 4 older comments
SatyaPrakash Gupta
SatyaPrakash Gupta on 15 Jun 2020
it has resolved my doubt but again last question on the same topic.
If i use fprintf('%.2e\n',matfile.y) to write on json file, i see there is a data loss ?
So in this case i can take %.10e to avoid data loss right ?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!