How can a function receive data randomly or generate random data as entry?

15 visualizaciones (últimos 30 días)
HI. I am looking for a function which I can enter data randomly or create a random data as a entry.
I work on text steganography in picture with MATLAB. I hope you can help me.
  11 comentarios
wafa suresh
wafa suresh el 5 de Jul. de 2021
Thank you so much for this example, I will test.
Scott MacKenzie
Scott MacKenzie el 5 de Jul. de 2021
Editada: Scott MacKenzie el 6 de Jul. de 2021
For what it's worth, here's something I put together to demonstrate @Walter Roberson's comment on "pairs of letters" -- that the message will look more natural if each letter is selected considering its probability of following the previous letter. Indeed, the output looks more natural (i.e., more like English).
df = readcell('digram.txt'); % digrams+frequencies, sorted by digram
n = size(df,1); % 27x27 = 729
letters = cellfun(@(x) x(1), df(1:27:length(df(:,1)),1));
letterFreq = (sum(reshape(cell2mat(df(:,2)), 27, [])))';
csLetterFreq = [1; cumsum(letterFreq)];
diagrams = char(df(:,1));
diagramFreq = cell2mat(df(:,2));
csDigramFreq = cumsum([ones(1,27); reshape(cell2mat(df(:,2)),27,[])]);
tot = sum(letterFreq); % total frequency (~300 million)
% create random message (begin with random letter selected as per letter freq)
message(1) = letters(find(randi(tot) <= csLetterFreq, 1));
for i=2:100
idx1 = find(message(i-1) == letters); % previous letter idx
idx2 = find(randi(csDigramFreq(end,idx1)) <= csDigramFreq(:,idx1), 1) - 1; % next letter idx
message(i) = letters(idx2);
end
message = strrep(message, '_', ' ') % replace underscore with space
message = 'aghesthif be ngole tthef is s y ms jup citoses in in winomaledwethe osther h e bams sthe he corithon'

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by