The sum of positive elements of a matrix
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
merowing3
le 18 Sep 2018
Commenté : Christopher Wallace
le 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 commentaires
Réponse acceptée
Plus de réponses (1)
Mohamed Hossam
le 14 Jan 2021
is there a certain command that gets the sum of postive even numbers of an array?
1 commentaire
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!