Hi,
There are many possible solutions :
Solution 1 :
The simplest is to use the principle of superposition due to linearity of the integrals. Thus, using the linearity of integrals, you could compute the required integral as :
Integral_of_f = Integral_of_f_Over_Rectangle - Integral_of_f_Over_all_holes;
Integral_of_f_Over_Rectangle can be computed numerically using the 'integral2' function as explained here :
Integral_of_f_Over_all_holes is the summation of integrals of 'f' over each of these holes. Assuming the holes are circular, the integral could be computed using one of the following ways :
a. Convert to polar coordinates and then use 'integral2' function
b. Mesh the circular hole and then use specialized quadrature rules for triangles. You can mesh the geometry using the PDE toolbox function 'generatemesh'. Please see the following for more details :
c. Directly integrate over circular regions using specialized quadrature rules developed for disks. For instance, you could use the weights and nodes as given by the following function (accounting for the difference in radius) :
Solution 2 :
Alternatively, you can do the following :
1. Create a 2D geometry with holes using CSG operations as explained here (using PDE toolbox) :
2. Generate a triangular mesh of the geometry from step 1 using 'generateMesh' function
3. Use triangular quadrature rule over every triangle of the mesh to compute the integral of 'f' over each of those triangles and then sum the result. You can use one of the following MATLAB file exchange submissions to generate the any order quadrature rule for a triangular element :
https://www.mathworks.com/matlabcentral/fileexchange/9230-gaussian-quadrature-for-triangles https://www.mathworks.com/matlabcentral/fileexchange/9435-n-dimensional-simplex-quadrature
Hope it helps!
Best Regards,
Vaidyanathan