Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


dpb
Posts:
8,187
Registered:
6/7/07


Re: Counting problem
Posted:
Feb 6, 2013 5:07 PM


On 2/6/2013 3:40 PM, Erasmus wrote: > hello everyone, I want count how many times of number meet the specific > criteria. > for example, I have two matrix, A and B, I want to count the how many > times of element meet two criteria,1) the element in A is less than 1; > 2) the corresponding element(in the same location) in B is larger than 50,. > > for example > > A= [ 0.1 0.2 0.5 > 0.9 1.3 1.2 0.7 1.2 1.5] > B=[2 34 43 > 54 55 56 > 62 43 45] > > so meet the times meeting these two criteria is 2 times, location[3,1] > and [2,1] >
>> ix=find(A<1); >> iab=intersect(ix,find(B(ix)>50)); >> N=length(iab) % count N = 2 >> [i,j]=ind2sub(size(A),iab); >> disp([i j]) % locations 2 1 3 1 >>




