필터 지우기
필터 지우기

Greater than is giving inconsistent answer

조회 수: 1 (최근 30일)
Amanda Beatty
Amanda Beatty 2021년 9월 9일
편집: Amanda Beatty 2021년 9월 9일
I am running two (slightly different) matalb programs in two different windows and getting incosistent answers on a very simple "greater than" equation. It is baffling me. 0.0417 is SOMETIMES > 0.0417, but not other times.
What am I missing here?
Window #1
Window #2

채택된 답변

Image Analyst
Image Analyst 2021년 9월 9일
They're probably off in the 15th decimal place or something. Try this
format long
If that doesn't work try
fprintf('%30f\n', ans2);
There should be a difference somewhere. See the FAQ:
  댓글 수: 1
Amanda Beatty
Amanda Beatty 2021년 9월 9일
편집: Amanda Beatty 2021년 9월 9일
They're still identical with format long and the fprintf you suggested, but using
sprintf('%20.18f\n',ans2)
from the link you posteds shows that they are different on the 17th decimal. Thank you! It looks like that originates from an interp1 calculation a while back in the code.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by