Azzera filtri
Azzera filtri

How to give randi values in different columns of matrix

1 visualizzazione (ultimi 30 giorni)
pop_size=100;
V=13;
b=randi([0 1],pop_size,V);
%100*13 matrix
I want randi values [0 1] in first two columns with constraint c1 != c2
means if c1=1 then c2=0 same as if c1=0 then c2=1.
Please help me how I can do?

Risposta accettata

Fangjun Jiang
Fangjun Jiang il 17 Ago 2016
just add this?
b(:,2)=~b(:,1)
  3 Commenti
Fangjun Jiang
Fangjun Jiang il 17 Ago 2016
after the line b=randi([0 1],pop_size,V);
Asad Abbas
Asad Abbas il 17 Ago 2016
Thank you so much Sir. Its working. I am very happy. bundle of thanks.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by