Summation of values > 1 in a cell array
Show older comments
Suppose I've a cell array;
cnt{1}=[3;1;3;2;1;2]
I would like to sum up the values which are > 1 ie the answer should return 10 (3+3+2+2)
I've tried using 'find' but the answer only returns the indices of the values > 1 and not the values.
ind=(find(cnt{1}>1))
How can I go about this? Please give me some hint.
Accepted Answer
More Answers (1)
ind=(cnt{1}>1);
sum(cnt{1}(ind)),
Categories
Find more on Creating and Concatenating Matrices 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!