In cryptography, the intended message sometimes consists of the first letter of every word in a string
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:7| Question number:25.7
All Answers
total answers (1)
crypt.m
function message = crypt(instring);
% This function returns the message hidden in the
% input string, which is the first letter of
% every word in the string
% Format crypt(input string)
% Returns a string consisting of the first letter
% of every word in the input string
rest = strtrim(instring);
message = '';
while ~isempty(rest)
[word, rest] = strtok(rest);
message = strcat(message,word(1));
end
end
need an explanation for this answer? contact us directly to get an explanation for this answer