If then statement vs Grid

I’m not sure why you’re using ranges for this. Why not:

u(x,y) = y - (x != 0)

or

u(x,y) = x == 0 ? y : y - 1

?

That’s just the function FC(x) = x != 0, or simply the function !iszero. (A boolean value true/false in Julia corresponds to 1/0, respectively.)

1 Like