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!