pseudorandom code pattern generator

i need a code to generate a m pseudo random code pattern having a length n each in order to spread the watermark bits

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 6 月 2 日

0 投票

randi([0 1], m, n)

2 件のコメント

uthara ravi
uthara ravi 2016 年 6 月 2 日
編集済み: Walter Roberson 2016 年 6 月 2 日
thank you sir. but i need the same in the following form. for eg.
1110
0101
0001
like an N by 1 matrix. is it possible?
Walter Roberson
Walter Roberson 2016 年 6 月 2 日
If you only need it for display purposes, then
char('0' + randi([0 1], m, n) )
or
dec2bin( randi([0 1], m, n) )
However, if you need it as an N x 1 numeric object, then you have the problem that there are no MATLAB numeric objects which will automatically format with leading 0's.
The code I showed would present a numeric array such as
1 1 1 0
0 1 0 1
0 0 0 1
and that should be fine for the purpose of spreading out bits in a watermark for anything short of doing a ga (genetic algorithm) specified as a bitstring .
I would advise, however, that if you are interested in spreading out bits, that what you probably really want is for there to be a specific number of 1 bits in the overall result. The way to do that is:
V = [ones(1, number_of_1s), zeros(1, number_of_0s)];
M = reshape( V(randperm(length(V))), m, n );

サインインしてコメントする。

Negongo  Usiku
Negongo Usiku 2020 年 2 月 24 日

0 投票

Prompt the user if they would like to continue If the response is yes Print “The Struggle Continues “ Otherwise if the response is No Print”I am a Chicken, Ending here.” Else if the response is none of the above Print “I don’t even know my name“ End Print “Thank you. Have a nice day!”

1 件のコメント

Steven Lord
Steven Lord 2020 年 2 月 24 日
This doesn't appear related to the original question. Please delete this answer and post it as a new question if you need help implementing it.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2016 年 6 月 2 日

コメント済み:

2020 年 2 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by