How to generate binary vector ?
显示 更早的评论
How to generate a vector of unique ( deterministic not random ) sequence of bits ?. I want a binary vector to use in many different codes for comparison
10 个评论
James Tursa
2019-3-28
There are many ways of doing this. Please give us more detail about your problem.
Walter Roberson
2019-3-28
Which deterministic algorithm do you want?
yousef Yousef
2019-3-28
Walter Roberson
2019-3-28
编辑:Walter Roberson
2019-3-28
oldstate = rng('twister', 54321); a = randi([0 1], 1, n); rng(oldstate);
yousef Yousef
2019-3-28
Walter Roberson
2019-3-28
oldstate = rng(65432, 'twister'); a = randi([0 1], 1, n); rng(oldstate);
I choose an initial seed that happens to give exactly 50 1's and 50 0's for n = 100.
yousef Yousef
2019-3-28
Walter Roberson
2019-3-28
a = zeros(1, n); a(1:2:end) = 1;
yousef Yousef
2019-3-28
yousef Yousef
2019-3-28
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!