How to count the number of "" true "" and ""false"" in matrix
조회 수: 277 (최근 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에서 Structures에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!