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 commentaire

Image Analyst
Image Analyst le 1 Déc 2019
No idea what you want, but look at dec2bin() and/or bin2dec().

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 2 Déc 2019

0 votes

vals = [-1j, -1, 1, 1j];
m2 = reshape(m, 2, []);
idx = m2(1,:) * 2 + m(2,:) + 1;
output = vals(idx);

4 commentaires

salad9996
salad9996 le 2 Déc 2019
thanks
salad9996
salad9996 le 8 Déc 2019
Hi, from the complex symbols, any method that I can get back to orignal binary number which contain 0 and 1?
Walter Roberson
Walter Roberson le 8 Déc 2019
ismember to get an index. Use that as a row index into a 4x2 array.
[, idx] = ismember(Symbols, [-1j, -1, 1, 1j]);
bits = [0 0; 0 1; 1 0; 1 1] .';
bit_vector = reshape(bits(:, idx), 1, []);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by