MATLAB: Set a bin to count the data points for certain conditions

.bincount

Hi there,
I want to count the number of data values that are in this conditions
if it satisfies both conditions then count it
if dist>= R & dist<=(R+dr)
and
if dist1>= R1 & dist1<=(R1+dr1)
Please help.

Best Answer

idx = (dist >= R) & (dist<=(R+dr)) & (dist1>=R1) & (dist1<=(R1+dr1)); %all that meet criteria
count == nnz(idx); %how many of these were true?