How binary Random number generation upto n nodes ?

1 view (last 30 days)
ankanna on 15 Mar 2021
Commented: Jan on 24 Apr 2021
i was do this
clc;
clear all;
close all;
node = 3;
offset = 1;
L = (node-offset)*node/2;
c =2^L;
% Generate c binary values:
r = randi([0, 1], c,L);
disp(r);
output:
0 0 1
1 0 0
1 0 0
1 0 1
1 1 0
1 0 0
0 1 0
0 0 1
but i want
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
James Tursa on 15 Mar 2021
Your current code generates random patterns. But what you want is not random at all ... it is an ordered list. Why do you write you want random output but then show a non-random ordered list as what you want?

James Tursa on 15 Mar 2021
Here is how to get your stated desired output, but this is not random at all:
r = dec2bin(0:(2^L-1)) - '0';
Jan on 24 Apr 2021

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by