How to give randi values in different columns of matrix

1 回表示 (過去 30 日間)
Asad Abbas
Asad Abbas 2016 年 8 月 17 日
コメント済み: Asad Abbas 2016 年 8 月 17 日
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?

採用された回答

Fangjun Jiang
Fangjun Jiang 2016 年 8 月 17 日
just add this?
b(:,2)=~b(:,1)
  3 件のコメント
Fangjun Jiang
Fangjun Jiang 2016 年 8 月 17 日
after the line b=randi([0 1],pop_size,V);
Asad Abbas
Asad Abbas 2016 年 8 月 17 日
Thank you so much Sir. Its working. I am very happy. bundle of thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by