array addition

2 次查看(过去 30 天)
God'sSon
God'sSon 2011-5-18
Hello,
I am trying to perform simple array addition inside of my code but I am getting wrong answers because of the negative sign which is suppose to cancel out during the addition still remains in the final answer. can anyone please help.
a =
1.0879
0.0000
-0.0000
0.0000
0.0000
0.0000
-0.0000
0.1072
b =
-0.0879
-0.0000
0.0000
-0.0000
0.0000
-0.0000
0.0000
0.8928
c = a+b
ans 1.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 1.0000

采纳的回答

Andrei Bobrov
Andrei Bobrov 2011-5-18
c(abs(c)<100*eps)=0
  4 个评论
Andrei Bobrov
Andrei Bobrov 2011-5-18
Please read the <http://matlab.wikia.com/wiki/FAQ> part
"Why is 0.3 - 0.2 - 0.1 (or similar) not equal to zero?"
God'sSon
God'sSon 2011-5-18
thanks

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by