MATLAB: Upper case need help

function unscramble=latinCipher(scramble)
[str,shift]=strtok(scramble,' ');
shift=str2num(shift);
str=char(mod(double(str)-97+shift,26)+97);
unscramble=upper(str);
end
for my this code, if I put lowercase 'sknz 4' it will output as 'WORD'. How could be fixed by puting uppercase 'SKNZ 4' would output as 'WORD". Because for now if I input 'SKNZ 4' it showed an unexpected value.

Best Answer

str=char(mod(double(lower(str))-97+shift,26)+97);