How can I count how many multi-dimension arrays in a matrix?
이전 댓글 표시
For example, I have a 10 by 2 matrix 'B' as below.
B=[1 9; 2 9; 4 8; 1 0; 1 0; 1 1; 1 3; 1 3; 1 2; 1 2]
I want to find out how many rows are 1 2 The answer should be 2. I am using for loop as shown below.
z=0;
for f1=1:10
if B(f1,1)==1 && B(f1,2)==2
z = z+1;
end
end
This method works fine but when matrix 'B' gets bigger, it takes too much time. Is there any other ways to do this job?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!