MATLAB: How to write a program, and shuffles only the inner letter of the word

scrambleshuffleword

How to write a program, and shuffles only the inner letter of the word, but leave the first and last letter of the word alone? Thank you

Best Answer

  • Try this:
    word = 'abcdefgh'
    middleIndexes = randperm(length(word)-2) + 1
    newWord = [word(1), word(middleIndexes), word(end)]