MATLAB: Integral2 input/output question

integral2

Hello, I am trying to integrate the letter "L" using integral2.
The function I'd like to integrate is:
function s = letterL(x,y)
if (abs(x) <= .1 && y >= -.1 && y <= 1) || (abs(y) <= .1 && x >= 0 && x < 0.5)
s = 1;
else
s = 0;
end
Now, that code is designed to take scalar inputs, but integral2 wants a function that takes arrays. Can anyone help me convert this to something I could use with integral2?

Best Answer

function s = letterL(x,y)
s = (abs(x) <= .1 & y >= -.1 & y <= 1) | (abs(y) <= .1 & x >= 0 & x < 0.5);
Provided that if both x and y are non-scalar that they must be the same size.