0

I'm looking for a matlab command that integrates a known function inside a triangle (which is known by his nodes).

I have 3 coordinates (x1,y1) (x2,y2) (x3,y3) that define a triangle and I know that inside the triangle there exist a known function f(x,y). I'm looking for a command that computes the integral of f over the triangle.

StefanM
  • 797
  • 1
  • 10
  • 17

1 Answers1

0

Use integral2 command in Matlab. The first example in the Documentation will cover your case. To get one side of your triangle parallel to the x-axis you can multiply your triangle with a rotation matrix and then "move" it on the x-axis.

Note that the integral is not influenced this transformations if your perform your substitutions correctly. This transformations can make it easier to write your code but they're not necessary to use integral2.

StefanM
  • 797
  • 1
  • 10
  • 17
  • Well, i also need to update F function as well, can u please write it ? suppose that three coordinates are given and also F in a known function. – user2600366 Sep 28 '16 at 11:04
  • F is a function recived from interuplated data. It's not analytic like F(x,y)=x or so. – user2600366 Sep 28 '16 at 11:12
  • If your data is interpolated you can use this: http://stackoverflow.com/questions/11559025/define-function-as-interpolation-of-x-y-data and then set the handle into `integral2`. – StefanM Sep 28 '16 at 15:24