I have a problem and then I need your help to solve it.
I have a matrix A
A = [ 0 0 1 2 3 4 0;
1 2 3 4 0 0 0;
0 0 0 1 2 3 4;
0 1 2 3 4 0 0]
and then I want to know how many number of each values “1” of each rows in matrix A which is not in the same column with each value “>=3” of each rows in matrix A.
so I wish that my answer
Ans = 2
Thanks before.
Try this:
First we find the columns indices containing no values greater or equal to 3
idx = all(A<3).Next in those columns
A(:,idx), we find the rows containing any 1:any(A(:,idx)==1,2).Finally we count how many such rows were found
sum(.)