MATLAB: Encrypting a message in matlab

encryptionhomework

For the attached document, were supposed to encrypt a message, and I got the numbers to come out, but when I try to convert it back to a message it just displays the original message instead of the secret code. I'll attach my code, I have no idea whats wrong with it, and why it isnt working. Thanks.

Best Answer

Nick - look closely at your for loop
for k=1:1
k is only ever going to be one. You need to iterate over each element of the number_message array. Hint: use length to do so.
Also, take a look at your code to add the key to the number_message array. Remember that the array is an array of doubles. What is the data type for your key?