Random string generation of message

6 visualizaciones (últimos 30 días)
Roger Nadal
Roger Nadal el 24 de Nov. de 2019
Comentada: Walter Roberson el 27 de Nov. de 2019
I have to pass (3,’hello’) it should return random characters between the message between each pair of letters like’habceabdlghflvcxo’

Respuestas (2)

Bhaskar R
Bhaskar R el 24 de Nov. de 2019
Assuming you are dealing with row string
function out_str = rand_string_gen(np, str)
% np = numberf of positions
% str = input string
out_str = []; % initialize output string with empty
for ii = 1: length(str)-1
ram_str = char(randi([double('a'), double('z')], 1, np));
out_str = [out_str, str(ii), ram_str];
end
% your output string out_str
out_str(end+1) = str(end);
end
  5 comentarios
Roger Nadal
Roger Nadal el 26 de Nov. de 2019
How to print all word in text that are together and how many time they appear one word per line order from most to least?
Walter Roberson
Walter Roberson el 27 de Nov. de 2019
Please start a new Question for that. When you do, indicate whether you have the Text Analytics Toolbox, and define exactly what a "word" is for your purposes.

Iniciar sesión para comentar.


Guillaume
Guillaume el 24 de Nov. de 2019
function out_str = rand_string_gen(np, str)
out_str = regexprep(str, '.(?!$)', sprintf('$0${char(randi(double(''az''), 1, %d))}', np));
end

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by