File Exchange

image thumbnail

intpoly(f,x,y)

version 1.0.0.0 (1.06 KB) by Liutong
Double Integration over a polygonal region.

1 Download

Updated 25 Mar 2017

View License

z=intpoly(f,x,y) integrate function f(u,v) over the polygon, which is defined by vertices [x,y]

input:
-f: a function handle, for example f=@(x,y) exp(x+y)
-x,y: vertices of the polygon. the (x1,y1),(x2,y2)... vertices can be either in clockwise order or counterclockwise order
ouput:
-z: the value of function f integrated over the polygon
example:
fill([0,1,2],[0,1,0],'b') %this is the triangle region

f=@(x,y) exp(x+y);
z=intpoly(f,[0,1,2],[0,1,0]) will integrate f over the triangle region defined by its three verteces (0,0), (1,1) and (2,0)

ans=4.1945

Comments and Ratings (2)

when an edge is parallel with x or y axis, this function cannot work. It is due to the fact that interp1 cannot calculate ymin or ymax in such a case.

Updates

1.0.0.0

refine the description

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux