sum logical 1's independently for each column
1 view (last 30 days)
Show older comments
I've attached a sample data from excel.
how can I create a "for loop" to sum each column and give me print out total for each column.
I also need to compare the "length" of the column to the sum of the logical 1's in that column then print out a pass or fail for each column tested.
example:
1 1 1 1
1 1 1 1
1 1 1 0
1 1 1 1
-----------sum
first column = 4 ==length(column) = pass
fourth column = 3 == lenght(column = fail
0 Comments
Accepted Answer
More Answers (2)
David Hill
on 12 Feb 2022
No loop is needed.
r=readmatrix('logicalDataCount.xlsx');
s=sum(r);
l=s==size(r,1);
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!