Generating n bit random numbers with each bit sampled N times.
Show older comments
I want to generate a random sequence of n bits, and each bit is to be sampled by 100 samples. Although i have generated the n bit sequence, how should i sample each bit.
bin_seq = randi([0 1],1,num_bit);
This is what i wrote for generating the n bit sequence where num_bit is the bumber of bits.(20 in my case)
Accepted Answer
More Answers (1)
Bruno Luong
on 18 Feb 2022
Edited: Bruno Luong
on 18 Feb 2022
n=8; % number of bits
r=10; % number of bit repetitions, 100 in your case
m=20; % number of sequenes (>=r)
i=zeros(r,n);
for k=1:n
i(:,k) = randperm(m,r);
end
j=repmat(1:n,[r,1]);
b=accumarray([i(:),j(:)],1,[m n]);
disp(b)
sum(b,1)
Categories
Find more on OFDM in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!