Difference between the usage of sum functions
조회 수: 3 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
채택된 답변
madhan ravi
2018년 10월 17일
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
madhan ravi
2018년 10월 17일
편집: madhan ravi
2018년 10월 17일
you’re welcome you can also vote for the answer
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!