How to extract only postive values from a n x n matrix
5 views (last 30 days)
Show older comments
I have a 100X100 matrix with negative and positive values, and i need to find the sum of each row for values that are greater than zero.
0 Comments
Accepted Answer
Guillaume
on 24 May 2015
m = randi([-20 20], 100); %demo data
sum(m .* (m>0), 2)
would work. Basically, replace negative numbers by 0 and take the sum.
0 Comments
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!