This script computes Gauss nodes and weights for numerically integrating a fuction over an arbitrary triangular domain. Note: This method uses the collapsed square rather than the general cubature case.
First, the area would not be 1, but rather 1/2. Second, you need to define a function like f=@(x,y) 1+0*(x.*y) to make sure it returns something with the correct dimension. Alternately, you could just sum the weights to get the area.
Comment only
30 Oct 2006
marki bugs
say vertices are (0,0), (1,0), (0,1)
I see this function & example works well, but besides f=(x,y) 1. I understand if I insert f=(x,y) 1, i should get the area of the triangle back. But I don't, am I not doing something wrong?
Comment only
12 Aug 2006
John D'Errico
Garrett defined his function improperly. The lack of a dot can be important in matlab.
f=@(x,y) x.^2 + exp(y);
Comment only
09 Aug 2006
Garrett Baird
I must be doing something wrong, because I can't get this to work for me. For example