MATLAB: Help with integral2 calculator

integralintegral2integrationnumerical integration

I'm trying to create a basic double integral calculator. How do I refine the code I have so far?
fun = @(x,y) input('enter integrand = ')
xmin = @(y) input('enter lower x boundary = ')
xmax = @(y) input('enter upper x boundary = ')
ymin = @(x) input('enter lower y boundary = ')
ymax = @(x) input('enter upper y boundary = ')
Q = integral2(fun,xmin,xmax,ymin,ymax)

Best Answer

Use the str2func (link) function. I would also use vectorize (link):

fun = input('enter integrand = ', 's') 
fun = str2func(['@(x,y) ' vectorize(fun)])
Q = integral2(fun, xmin, xmax, ymin, ymax)