I have the following code that, if a value in A is greater than a corresponding value in B, will replace that value with the value in B, returning the result as C.
How could I rewrite this without loops? Thanks in advance.
C=[];[m n] = size(A);for i = 1:m for j = 1:n if A(i, j) < B(i, j) C(i, j) = A(i, j); else C(i, j) = B(i, j); end endenddisp(C);
Best Answer