The sum of positive elements of a matrix
조회 수: 11 (최근 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!