I have this function that is supposed to, taking into consideration, certain constraints construct a grid. My question is why even though I have an if conditional that is supposed to be false it evaluates true. I have commented the part with the values. Any ideas why this is happening?
The function is:
function b = inside(x,y)
rightwall = @(y) y+0.16;
leftwall = @(y) y+0.1;
b = false;
if y < 0.04 && y > 0
if x < rightwall(y)
b = true;
end
elseif y >= 0.04 && y <0.06
if x > leftwall(y) && x < rightwall(y)
lw = leftwall(y) % lw = 0.1400 is equal to x and if statement
% should not run
rw = rightwall(y) % lw = 0.2000
x = x % lw = 0.1400
b = true;
end
elseif y >= 0.06 && y <= 0.20
if x > 0.16 && x < 0.20
b = true;
end
end
end