The sum of positive elements of a matrix
13 次查看(过去 30 天)
显示 更早的评论
Let M be a matrix with dimensions mxn. Calculate the sum of all positive elements of matrix M without using loop.
My code:
sum(M>0) % sum of all positive elements in respective column, we get vector with sum for each column
sum(sum(M>0)) % sum of all sums from vector
Correct or not?
0 个评论
采纳的回答
更多回答(1 个)
Mohamed Hossam
2021-1-14
is there a certain command that gets the sum of postive even numbers of an array?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!