Mapping two binary bits to one

조회 수: 3 (최근 30일)
salad9996
salad9996 2019년 12월 1일
댓글: Walter Roberson 2019년 12월 9일
I have generate a set of bits 0 and 1,
N=10000;
m=(sign(randn(1,N))+1)/2;
The problem is how do I group the bits? For example
00=-j
01=-1
10=1
11=j
  댓글 수: 1
Image Analyst
Image Analyst 2019년 12월 1일
No idea what you want, but look at dec2bin() and/or bin2dec().

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2019년 12월 2일
vals = [-1j, -1, 1, 1j];
m2 = reshape(m, 2, []);
idx = m2(1,:) * 2 + m(2,:) + 1;
output = vals(idx);
  댓글 수: 4
Walter Roberson
Walter Roberson 2019년 12월 8일
ismember to get an index. Use that as a row index into a 4x2 array.
Walter Roberson
Walter Roberson 2019년 12월 9일
[, idx] = ismember(Symbols, [-1j, -1, 1, 1j]);
bits = [0 0; 0 1; 1 0; 1 1] .';
bit_vector = reshape(bits(:, idx), 1, []);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by