How can I do such a "countifs"(excel) process in Matlab?
83 ビュー (過去 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!