SAS_TriangleArea Function
%%%%%%%%%%%%%%%%%%%%%%%%%
function [ triangleArea ] = SAS_TriangleArea( a, b, alpha )
%SAS_TriangleArea Finds Triangle Area by using side-angle-side
triangleArea = (1/2)*a*b*sind(alpha);
end
%%%%%%%%%%%%%%%%%%%%%%%%%
%SSS_TriangleArea Function
function [ triangleArea ] = SSS_TriangleArea( a, b, c )
%SSS_TriangleArea computes area of side-side-side triangle
S = (a + b + c)/2;
triangleArea = sqrt(S*(S-a)*(S-b)*(S-c));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Test Case 1
w = 1;
x = 1;
z = 1;
y = sqrt(2);
alpha = 90;
triangle1 = SAS_TriangleArea(w,x,alpha);
triangle2 = SSS_TriangleArea(x,y,z);
triangleArea = triangle1 + triangle2;
fprintf('The area for Test Case 1 is: %3.2f', triangleArea)
Best Answer