From: Walter Roberson on 24 May 2010 19:21 alfann wrote: > U1=[22 22 22 22; 66 77 88 99; 10 11 12 13; 14 15 16 17; 0 0 0 0] > and > U2=[0 0 0 0; 0 0 0 0; 0 1 0 0; 0 1 0 0; 0 0 0 0] > Then > I want calculate U3 which is equal to: [..] > but with this condition: > The location of U1(i,j) must be equal to zero in U2 What should happen if U2(i,j) is non-zero? Does that just mean U3(i,j) should be 0, or NaN, or some other fixed value? Or does it mean that each place in the formula where U1(P,Q) would be fetched (e.g, via U1(i,j+1) ) that the corresponding location in U2 should be checked and if that location is non-zero then that U1(P,Q) should not be used? Should 0 be substituted instead, or should that term drop out of the summation and the denominator 4 be reduced accordingly? If U3(i,j) should simply assume some fixed value if U2(i,j) is non-zero, then probably the easiest thing to do is to compute all of U3 first and then to set U3(U2 ~= 0) = TheFixedValue; |