How can I do such a "countifs"(excel) process in Matlab?
조회 수: 73 (최근 30일)
이전 댓글 표시
How can I do such a "countifs"(excel) process in Matlab?
댓글 수: 0
답변 (3개)
Stephan
2021년 4월 18일
A = randi(10,1,15)
CountIf = numel(A(A>5))
gives:
A =
9 7 4 10 1 5 4 8 8 2 5 5 7 8 8
CountIf =
8
댓글 수: 0
Simon Fu
2021년 8월 6일
Another way is to take advantage of the fact that logical in MATLAB has the value of 1 for true, and 0 for false.
So, using sum function would gives the same result as the previous answer of using numel; i.e.:
A = randi(10,1,15)
CountIf = sum(A>5)
gives:
A =
9 7 4 10 1 5 4 8 8 2 5 5 7 8 8
CountIf =
8
댓글 수: 0
Saad Arshad
2022년 1월 11일
The best way to perform the equivalent of a COUNTIFS function in MATLAB is to first convert your data into a table and then use the GROUPCOUNTS function. Details: https://www.mathworks.com/help/matlab/ref/double.groupcounts.html
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!