I have two matrices in MATLAB lets say arr1
and arr2
of size 1000*1000 each. I want to compare their elements and save the comparison in a result matrix resarr
which is also 1000*1000 such that for each element:
- if the element in
arr1
is bigger than the one inarr2
, place the value 1 in the result - if the element in
arr2
is bigger, store the value 2
but I don't want to do this with for loops because that is slower. How can I do this?
EDIT:
Also if I wanted to store different RGB values in a 1000*1000*3 result matrix, depending on the comparison of arr1
and arr2
, could that be done without slow loops?
For example store (255,0,0) if arr1
is larger and (0,255,0) if arr2
is larger