number format comparison difficulty

조회 수: 1 (최근 30일)
Vanessa
Vanessa 2017년 7월 27일
댓글: Stephen23 2017년 7월 27일
Hello everyone!!
Here is my problem. Matlab considers that 3.9438e+04 and 39438 are not the same!! How may I fix this? What conversion should I make?
Thank you, Vanessa
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2017년 7월 27일
Vanessa - please clarify what you mean by MATLAB not considering these two numbers to be the same. Are you trying to perform some equality check and that is failing? Or is it that visually they don't appear the same in the command window? (In which case you can format the data using Set Command Window output display format.
Stephen23
Stephen23 2017년 7월 27일
It works for me:
>> 3.9438e+04 == 39438
ans = 1
"Matlab considers that 3.9438e+04 and 39438 are not the same"
Most probably those two variables do not have the same values. Have you tried viewing the numbers at a higher precision, e.g. by changing the format or using sprintf ?

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

답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by