MATLAB: Using conditional IF statement

if condition statementMATLAB

I have a matrix A and I generate B=randi([0,1],7,3).I want C=A*B only if sum of each row of B=1..I tried this..
A=[1 0 0 1 0 1 1
0 1 1 1 0 0 1
1 0 0 1 1 0 0
1 0 0 0 1 0 1
1 1 0 0 0 1 0
0 1 0 0 0 1 1]
for k=1:numIterations
B=randi([0,1],7,3);
if sum(B,2)==1;
C=A*B;
end
end
how to use IF condition in this case?

Best Answer

if all(sum(B,2)==1)