Random substitution for QAM symbols

Hi everyone, I want to do a random substitution for QAM symbols based on secret key or random vector.
For example, suppose 4-QAM modulation with the following substitution:
(00) is substituated to (10) ,
(01) is substituated to (00),
(10) is substituated to (11), and
(11) is substituated to (01).
Based on a secret key, the subsituation box is changed.
May you guide me how to do that in matlab with any M-ary QAM?
Thanks in advance.

답변 (2개)

Walter Roberson
Walter Roberson 2020년 11월 11일
편집: Walter Roberson 2020년 11월 11일

0 개 추천

lookup = [1 0; 0 0; 1 1; 0 1]; %must be in numeric order
output = reshape(lookup([2 1] * reshape(VectorOfBits, 2, []) + 1, :).', 1, []);
The [2 1]* is converting from 2 bit binary into decimal. Then +1 to get a 1-based index, that is used to index into the lookup table of replacements. The rest has to do with arranging bits in the right order for processing.
There are other ways, such as
output = reshape(lookup(VectorOfBits(1:2:end)*2 + VectorOfBits(2:2:end) + 1,:).', 1, []);
and some of the work can be made easier if you make the lookup table column-oriented instead of row oriented.

댓글 수: 2

YAHYA AL-MOLIKI
YAHYA AL-MOLIKI 2020년 11월 18일
편집: YAHYA AL-MOLIKI 2020년 11월 18일
Thank you Mr. Walter. Unfortuently, your code doesn't implement a corect subsistution.
Walter Roberson
Walter Roberson 2020년 11월 18일
I tested the code before I posted. Both versions work according to the requirements that were given.

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

YAHYA AL-MOLIKI
YAHYA AL-MOLIKI 2020년 11월 18일
편집: YAHYA AL-MOLIKI 2020년 11월 18일

0 개 추천

I suggest the following code to implement substituation.
function y=substit(x,k)
y=zeros(length(x),2);
Rl=[0 0; 0 1; 1 0; 1 1];
Rm=randintrlv(Rl,k); %k is the secret key that is used to produce the substituation table.
for i=1:length(x)
switch binaryVectorToDecimal(x(i,:))
case 0
y(i,:)=Rm(1,:);
case 1
y(i,:)=Rm(2,:);
case 2
y(i,:)=Rm(3,:);
case 3
y(i,:)=Rm(4,:);
end
end
end
If there is another suggestion, you may share your codes.

댓글 수: 1

YAHYA AL-MOLIKI
YAHYA AL-MOLIKI 2020년 11월 18일
I suggest also the following code to implement inverse substituation as follows:
function y=invsubstit(x,k)
y=zeros(length(x),2);
Rl=[0 0; 0 1; 1 0; 1 1];
Rm=randintrlv(Rl,k);
Rmd=binaryVectorToDecimal(Rm);
for i=1:length(x)
switch binaryVectorToDecimal(x(i,:))
case 0
m=find(Rmd==0);
y(i,:)=Rl(m,:);
case 1
m=find(Rmd==1);
y(i,:)=Rl(m,:);
case 2
m=find(Rmd==2);
y(i,:)=Rl(m,:);
case 3
m=find(Rmd==3);
y(i,:)=Rl(m,:);
end
end
end

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

카테고리

질문:

2020년 11월 11일

댓글:

2020년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by