Can anyone help? I am trying to see if an array of three numbers inputted by a user can form a right triangle. My code is below and I can't figure out why it won't work. Thank you in advance!
sides =input('please enter 3 whole numbers in brackets [] : ');Sides = perms(sides);% generate an array of the permutations of the input
Triange=0% initiate count
for a = 1:3 for b = 1:3 for c = 1:3 if (Sides(:,a)^ 2)+ (Sides(:,b)^ 2) == (Sides(:,c) ^ 2); Tri(:,:) = [Sides(:,a),Sides(:,b),Sides(:,c)]; Triangle=Triangle +1 else disp('there are no right triangles') end end% for c
end% for b
end%for a
Best Answer