Filter löschen
Filter löschen

array addition

2 Ansichten (letzte 30 Tage)
God'sSon
God'sSon am 18 Mai 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

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 18 Mai 2011
c(abs(c)<100*eps)=0
  4 Kommentare
Andrei Bobrov
Andrei Bobrov am 18 Mai 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 am 18 Mai 2011
thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by