When i run this code, i want the H value to come out as an integer so that it will display smoothly, but it comes out as a matrix, and that why the fprintf function gets caught in a loop, ill assume. So, I'm new to this and haven't been taught enough at all, and definitely not enough to fix this, so any help would be appreciated. I've looked all over the help section, but couldn't find anything over this problem that i could understand. Ive tried putting num2str(x) in front of each printed variable. Thanks
clear;clc;A=input('What is the adjacent side of the right triangle with respect to angle T?', 's');O=input('What is the opposite side of the right triangle with respect to angle T?', 's');H=sqrt((O*O)+(A*A));func=menu('What trig function do you want to use?','Sin(T)','Cos(T)','Tan(t)');Sin=(O/H);Cos=(A/H);Tan=(O/A);if func==1; fprintf('For a triangle of sides %d',H,' ,%d',O,'and %d',A,' sin(T) equals %d',Sin);elseif func==2; fprintf('For a triangle of sides %d',H,' ,%d',O,'and %d',A,' cos(T) equals %d',Cos);elseif func==3; fprintf('For a triangle of sides %d',H,' ,%d',O,'and %d',A,' tan(T) equals %d',Tan);end
Best Answer