MATLAB: Using quad2d

dot productintegralquad2d

Hi, i am trying to use quad2d and running into the following problem: I've a functions defined , e.g.
f1 = @(x,y) x+y
f2 = @(x,y) x-y
f3 = @(x,y) x
f4 = @(x,y) y
I need to integrate dot([f1 f2], [f3 f4]). if I try quad2d(@(x,y) dot([f1 f2], [f3 f4]),a,b,c,d ) it isn't working. Any suggestions as how fix this? thanks

Best Answer

DOT doesn't work on function handles, and as Walter says, QUAD2D requires that the integrand be able to handle matrix input. You don't need all that reshaping, however:
quad2d(@(x,y)f1(x,y).*f3(x,y)+f2(x,y).*f4(x,y),a,b,c,d)