Sample Answer - Determine if 3
numbers form the sides of a triangle
function str_tri_test =
istriangle(a,b,c)
% istriangle determine if a,b,c form a triangle
v =[ a b c];
vsort=sort(v);
if vsort(1) + vsort(2) > vsort(3)
s1=['The sides ',num2str(v),' form a triangle.'];
% start extra credit
if (a==b) & (b==c) % all sides equal
s2=' The triangle is an
equialateral triangle.';
elseif (a==b) |(b==c) |(a==c)
s2= ' The triangle is an
isosceles triangle.';
else
s2= ' The triangle is a
scalene triangle.';
end
%end extra credit
str_tri_test=strcat(s1,s2);
else
str_tri_test= ['The sides ',num2str(v),' do not form
a triangle.'];
end try: >> istriangle(3,4,5)