%
disp(' ');
disp(' triangle_area.m  ver 1.0  June 13, 2012 ');
disp(' ');
disp(' by Tom Irvine  Email: tom@vibrationdata.com ');
disp(' ');
disp(' This program calculates the area of a triangle.  ');
disp(' ');
%
close all;
clear THM
clear area;
clear x;
clear y;
%
disp(' Select coordinate entry method ');
disp('  1=manual   2=Matlab array ');
icm=input(' ');
disp(' ');
%
if(icm==1)
    for i=1:3
        out1=sprintf(' Enter x%d:  ',i);
        x(i)=input(out1);
        out2=sprintf(' Enter y%d:  ',i);
        y(i)=input(out2);  
        disp(' ')
    end
else
   THM=input(' Enter array name: '); 
   x=THM(:,1);
   y=THM(:,2);
end
%
area=x(1)*(y(2)-y(3))+x(2)*(y(3)-y(1))+x(3)*(y(1)-y(2));
area=abs(area/2);
%
out1=sprintf('\n area = %8.4g  \n',area);
disp(out1);
%
figure(1);
xp=[ x(1) x(2) x(3) x(1) ];
yp=[ y(1) y(2) y(3) y(1) ];
plot(xp,yp);
title(out1);
grid on;
xlabel('x');
ylabel('y');
%