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 CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by