area

PURPOSE ^

AREA - compute areas for every element

SYNOPSIS ^

function areas=area(md)

DESCRIPTION ^

AREA - compute areas for every element

   Usage:
      areas=area(md)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function areas=area(md)
0002 %AREA - compute areas for every element
0003 %
0004 %   Usage:
0005 %      areas=area(md)
0006 
0007 areas=zeros(md.numberofelements,1);
0008 
0009 %load some variables (it is much faster if the variab;es are loaded from md once for all)
0010 index=md.elements;
0011 x=md.x; y=md.y; z=md.z;
0012 x1=x(index(:,1)); x2=x(index(:,2)); x3=x(index(:,3)); y1=y(index(:,1)); y2=y(index(:,2)); y3=y(index(:,3));
0013 
0014 %compute the volume of each element
0015 if strcmpi(md.type,'3d')
0016     %V=area(triangle)*1/3(z1+z2+z3)
0017     thickness=mean(z(index(:,4:6)))-mean(z(index(:,1:3)));
0018     areas=abs(0.5*((x2-x1).*(y3-y1)-(y2-y1).*(x3-x1)));
0019 else
0020     %compute the surface of the triangle
0021     areas=abs(0.5*((x2-x1).*(y3-y1)-(y2-y1).*(x3-x1)));
0022 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003