I have two matrices A and B and I want to perform an element wise maximum on them. I just wrote the following code which is very inefficient and takes a long time to run.
A = C;
for x = 1 : height
for y = 1 : width
if(A(x, y) < B(x, y))
A(x, y) = B(x, y);
end
end
end
I searched SO and figured out that similar questions have been answered using bsxfun
function (1, 2, 3). But I could not get the point.
can bsxfun
be applied here too?
What I want would be something like A = max(B, C)
.