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

    %% Integrate Triangular Region with Singularity at the Boundary  
% The function 
%
% $$f \left( x,y \right) = \frac{1}{\left( \sqrt{x+y} \right) \left( 1+x+y
% \right)}$$
%
% is undefined when $x$ and $y$ are zero. |integral2| performs best when
% singularities are on the integration boundary.   

%% 
% Create the anonymous function. 
fun = @(x,y) 1./( sqrt(x + y) .* (1 + x + y).^2 )  

%% 
% Integrate over the triangular region bounded by $0 \le x \le 1$ and $0
% \le y \le 1 - x$.
ymax = @(x) 1 - x;
q = integral2(fun,0,1,0,ymax)