function val = myint2d
x = [0 1 0];
y = [0 0 1];
t = [ 1 2 3];
trimesh(t,x,y);title('Triangular integration region','FontSize',14)
%%% use an appropriate flag when integrating different functions
%%% see tri_quadcofs for what flags are available
flag = 1;
[wq,xq,yq] = tri_quadcofs(mycoord(1,t,x,y),flag);

s = 0;
for r=1:length(wq)
    s = s + wq(r)*myfun(xq(r),yq(r));
end
val = s;

function carr = mycoord(num,t,x,y)
n1 = t(num,1); n2 = t(num,2) ; n3 = t(num,3);
carr = [x(n1) y(n1); x(n2) y(n2); x(n3) y(n3)];        


function z=myfun(x,y)
    z = ones(size(x));
    z = x.^2;% + y.^2;
   
    