function - How do I stop my switch statement from outputting the case in Matlab -
i trying write function can accomplish 3 tasks using menu statement in matlab, reason keeps outputting case number function answer.
function fcn=jon2(x) fcn=menu('choose function:','ceil','round','sign'); switch fcn case 1 ceil(x) case 2 round(x) case 3 sign(x) end end
when input 12 , select round, answers come out:
ans =
12
ans =
2
you need use function properly, if defined as: fcn=jon2(x)
should write each output using it:
... case 2 fcn = round(x); ...
also, use ;
suppress output command line...
Comments
Post a Comment