How to count the number of "" true "" and ""false"" in matrix
203 次查看(过去 30 天)
显示 更早的评论
matrix AAA is
AAA = [...
true true false true true
true true true false false
true false false true true
]
How to know
the number of ""true"" is 10 pcs
the number of ""false"" is 5 pcs
How to show a message "True is 66.7%"
0 个评论
采纳的回答
William Alberg
2020-5-25
You can do something like this:
a = [
true true false true true
true true true false false
true false false true true
]
TRUES = sum(a,'all')
FALSES = size(a,1)*size(a,2) - TRUES
0 个评论
更多回答(1 个)
Tommy
2020-5-26
How to show a message "True is 66.7%"
fprintf('True is %.1f%%\n', 100*TRUES/numel(a));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!