encodeCipher

encodeCipher - 'phones would become'psheon function code =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% 9/21/2009 6:57 PM % Function Name: encodeCipher % Inputs: a char string % Outputs: a char string % % Function Description: % Write a function that takes in a string and returns the string % rearranged such that the first letter is put with the last letter, then % the second letter and the second to last letter, etc. For example,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % 'phones' would become 'psheon'. % function code = encodeCipher(string) code = ; for i = 1:floor(length(string)/2) code = [code string(i) string(end-(i-1))]; end if(mod(length(string), 2) == 1) code = [code string(ceil(end/2))]; end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online