array addition

5 views (last 30 days)
God'sSon
God'sSon on 18 May 2011
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

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 18 May 2011
c(abs(c)<100*eps)=0
  4 Comments
Andrei Bobrov
Andrei Bobrov on 18 May 2011
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 on 18 May 2011
thanks

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!