How can I count how many multi-dimension arrays in a matrix?
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!