Filter löschen
Filter löschen

Difference between the usage of sum functions

3 Ansichten (letzte 30 Tage)
Benedikt Wessel
Benedikt Wessel am 17 Okt. 2018
Bearbeitet: madhan ravi am 17 Okt. 2018
Hey, can someone explain, why the results are different? And which way is the right one? Thanks.
X=A+B+C-D;
Sum1=sum(X)
Sum2=sum(A)+sum(B)+sum(C)-sum(D)

Akzeptierte Antwort

madhan ravi
madhan ravi am 17 Okt. 2018
SUM1 is the right one.
It calculates your resultant matrix’s sum
But the latter calculates the sum o each matrices and does the arithmetic operations but then also it depends on your wish.
  2 Kommentare
Benedikt Wessel
Benedikt Wessel am 17 Okt. 2018
Thanks!
madhan ravi
madhan ravi am 17 Okt. 2018
Bearbeitet: madhan ravi am 17 Okt. 2018
you’re welcome you can also vote for the answer

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by