MATLAB: Matrix value comparison of values

matrix

I have two surfaces in matrix form 200×200, M1 and M2. I want to set all values in M1 to NaN if they are higher than the corresponding values in M2. How would i go about this?
Thanks,
Luke

Best Answer

M1(M1>M2)=nan