Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我做了计算,得到了以下数字
0.739128438976901 0.739128438976900
我希望 MATLAB 认为它们是相等的,但 MATLAB 认识到第一个大于第二个。我怎样才能让 MATLAB 认为它们是平等的?
谢谢
x = 42 y = 42.00001 if abs(x-y) < tolerance % do something end
的设置由tolerance您决定。
tolerance
我对 Matlab 不太了解(我自己更像是一个 Mathematica 人),但似乎有一个roundn(x,n)函数可以将元素四舍五入x到最接近的 10^ 倍数n。也许这可以在这里使用。
roundn(x,n)
x
n