MATLAB: How to plot a triangle with the user’s measurments

plottriangle

Hey I am trying to plot a triangle with the user's measurements but I can't figure it out. Here is what I tried but it doesn't work.
elseif strcmp(h, 'triangle') a=input('The length of the first side is (m):'); b=input('The length of the second side is (m):'); c=input('The length of the third side is (m):'); plot([0 0],[b 0],[b a],[a c],'r','LineWidth',3) end

Best Answer

Just try:
ang = acos((a^2+b^2-c^2)/(2*a*b))
if(isreal(ang))
plot([0,a,b*cos(ang),0],[0,0,b*sin(ang),0])
end
I'm just using the cosene theorem.