MATLAB: Suppressing ans in a function

functionMATLABmatlab function

function encStr = encrypt(s,key);
prompt='Enter message to be encrypted: ';
s=input(prompt,'s');
key=input('Enter the key: ');
encStr=char(s+key);
fprintf('The encrypted message is: %s\n',encStr);
end
Hi this is my function above. I don't want to see an ans when I apply this function. I searched it online but most of the answers says that I should get rid of encStr in the function but I must use this format. Can you help me?
Thanks!

Best Answer

To avoid the ans you must use a semi-colon when you call the function:
str = encrypt(...);
% ^ you need this semicolon!