The sum of positive elements of a matrix
24 ビュー (過去 30 日間)
古いコメントを表示
merowing3
2018 年 9 月 18 日
コメント済み: Christopher Wallace
2021 年 1 月 14 日
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 で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!