필터 지우기
필터 지우기

create all logic permutation array

조회 수: 2 (최근 30일)
Nguyen Huy
Nguyen Huy 2021년 8월 11일
편집: DGM 2021년 8월 12일
how cloud i create all random logic array when the length is known
eg: length=3
arr=[ 1 0 0
0 1 0
0 0 1
1 1 0
0 1 1
1 0 1
1 1 1]

답변 (2개)

Yazan
Yazan 2021년 8월 11일
d = (1:2.^3-1)';
b = de2bi(d);
b
b = 7×3
1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1

DGM
DGM 2021년 8월 12일
편집: DGM 2021년 8월 12일
If you don't have the communications toolbox:
n = 3; % number of bits
LUT = dec2bin((0:2^n-1).',3)=='1'
LUT = 8×3 logical array
0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1
Note the bit order. Also, this example includes 0

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by