The sum of positive elements of a matrix
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
merowing3
am 18 Sep. 2018
Kommentiert: Christopher Wallace
am 14 Jan. 2021
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Mohamed Hossam
am 14 Jan. 2021
is there a certain command that gets the sum of postive even numbers of an array?
1 Kommentar
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!