www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/EvaluateDoubleIntegralExample.m

    %% Evaluate Double Integral
% Integrate 
%
% $$y \sin(x) + x \cos(y)$$
%
% over $-\pi \le x \le 2 \pi$ and $0 \le y \le \pi$.
fun = @(x,y) y.*sin(x)+x.*cos(y);
Q = quad2d(fun,pi,2*pi,0,pi)

%%
% Compare the result to the true value of the integral, $-\pi^2$.
-pi^2