Find the some of a row with numbers greater than -1 in matlab
2 views (last 30 days)
Show older comments
Aurelius Hardy
on 23 Nov 2022
Commented: Image Analyst
on 23 Nov 2022
Numbers in row 1 are: 103, 61, 0, 0, 62, -999, -999, 0, 0, 2
I'm using sum(B,2)
but how can I sum all rows greater than or equal to 0
Accepted Answer
Walter Roberson
on 23 Nov 2022
B = [103, 61, 0, 0, 62, -999, -999, 0, 0, 2]
sum( max(B, 0), 2)
3 Comments
Image Analyst
on 23 Nov 2022
@Aurelius Hardy please click the "Accept this answer link" to award @Walter Roberson reputation points and let others know it's already been solved. Thanks in advance 🙂.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!