MATLAB: How to calculate number that satisfy the condition

barconditionnumber

I have two 281×281 sets of matrix. A is a prescribed data whereby B is tracked data. I would like to calculate the difference of these two sets data and then calculate how many data that satisfy the condition.
For example, how many data satisfy condition <5, how many >5 and etc

Best Answer

C = double(A) - double(B);
nnz(C < 5)
nnz(C > 5)
Note: in some contexts, talking about the "difference" between the two would imply
C = abs(double(A) - double(B));