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 个评论
更多回答(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!