Matlab 2019 small numbers are displayed/converted wrong
Show older comments
Dear all,
I used to import a column of data values in the order of 1E-18 and in R2017b this worked perfectly fine, but the same code in the R2019b version displays/stores the values differently and somehow creates different numbers. Can someone explain this, here a simple illustration of the problem:

10 Comments
It sounds like the problem may be associated with floating point precision (roundoff error). How are you reading in the data and how are the data stored on file?
Kevin hofhuis
on 20 Mar 2020
Edited: Kevin hofhuis
on 20 Mar 2020
I have access to r2017b and r2019b and I could look into the difference but I still don't know how you're importing the data (I'd also need an example file). How do you know that there wasn't roundoff error in the 2017 import? Are you saying that you've checked the imported values against the actual values and they matched perfectly in 2017 but they do not match in 2019? Or are you saying that there's a difference in 2017 and 2019 import values and you're assuming that the error is with 2019?
Kevin hofhuis
on 20 Mar 2020
Well, then that's a completely different story. Your quesiton specifies a problem with importing data ("I used to import a column of data values...").
What does this command return?
get(0, 'format')
Kevin hofhuis
on 21 Mar 2020
Adam Danz
on 21 Mar 2020
Just to be clear,
- You're manually typing "1.6519862e-16" in the command window?
- When you shut down and restart Matlab the problem doesn't go away?
Some of those examples from your screenshot make sense. The first one,
>> format long
>> 1.6519862e-13 % manually typed in, as-is
ans =
1.651986200000000e-13
format short
>> 1.6519862e-13
ans =
1.6520e-13
But other examples from your screenshot do not make sense.
Kevin hofhuis
on 21 Mar 2020
Adam Danz
on 21 Mar 2020
The first 3 examples from your screenshot are fine. The difference you see it just due to the long format. The last two examples are a mystery to me. If it happens again, copy your recent command history and any errors/warning you recently received so you have some idea of what may be causing the problem.
Kevin hofhuis
on 21 Mar 2020
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!