MATLAB: New to Matlab- how to do a calculation on a variable without creating a matrix

calculationfunctionintegermatrixnew

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

Input your values as numbers instead of as strings by dropping the 's' argument. Also, change your fprintf statements so that all of the format string appears as the 1st argument and then all of the variables you are printing comes next. And when using fprintf, be sure to put a newline \n at the end so that the command line prompts will appear on the next line. E.g.,
clear;
clc;
A=input('What is the adjacent side of the right triangle with respect to angle T? ');
O=input('What is the opposite side of the right triangle with respect to angle T? ');
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 and %d, sin(T) equals %d \n',A,O,Sin);
elseif func==2;
fprintf('For a triangle of sides %d and %d, cos(T) equals %d \n',A,O,Cos);
elseif func==3;
fprintf('For a triangle of sides %d and %d, tan(T) equals %d \n',A,O,Tan);
end