Matlab 2019 small numbers are displayed/converted wrong

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

Adam Danz
Adam Danz 2020년 3월 20일
편집: Adam Danz 2020년 3월 20일
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
Kevin hofhuis 2020년 3월 20일
편집: Kevin hofhuis 2020년 3월 20일
Hi, thanks for answering so quickly. I'm just confused as to why in 2017 importing such numbers didn't cause any roundoff errors, while now in 2019 it does. It's not just a problem when importing, even in the command window it's now different. I'm asking how the storing of the numbers is different. I hope I'm clear
Adam Danz
Adam Danz 2020년 3월 20일
편집: Adam Danz 2020년 3월 20일
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?
Is the difference you're seeing a difference in format style?
Its not a matter of importing, I tried to make the problem as basic as possible and if you look at the attached image, you can see that if I type in a number, the displayed number is different. I'm trying to understand why it does this.
Adam Danz
Adam Danz 2020년 3월 20일
편집: Adam Danz 2020년 3월 20일
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')
the command returns: 'long'
Just to be clear,
  1. You're manually typing "1.6519862e-16" in the command window?
  2. 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.
  1. Yes, I was typing in the number manually
  2. Restarted and now I cannot reproduce the error manually
Could it have been a memory error of some sort?
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.
Thank you for your patience! It seems this wasn't an issue between matlab versions nor the importing and solved by restarting the application. The cause I do not understand, but I will keep an eye on it in the future.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

질문:

2020년 3월 20일

댓글:

2020년 3월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by