Are you sure that word will be datatype string() and not character vector?
guessedWord = input('Enter guess or Q to quit: ');
input() with no 's' option evaluates what the user types, so the user would have to type '' or "" around their input. Consider using the 's' option, which would return a character vector
if guessedWord == 'Q'
You should not rely upon the user having deliberately entered a string object: even if they remember that they need to enter characters, there is too much chance they might user '' instead of "" . And if they do, then using == 'Q' is not going to work like you want. When you compare a character vector to a scalar character, the test is equivalent to
if all(all(guessedWord == repmat('Q', size(guessedWord))))
If you knew that guessedWord was a string() object then the string == operator would be invoked instead of the character == operator. Or if you had used
if guessedWord == "Q"
then it would be the string() == operator.
word = randperm((word));
That should be something like
cword = char(word);
cword = cword(randperm(length(cword)));
if ischar(word)
word = cword;
else
word = string(cword);
end