solpoiuy 发表于 2007-4-21 14:03

怎么实现差分编码?

各位达人,小弟初学MATLAB,最近碰到问题
不知道怎么用MATLAB实现差分编码.
比如:
m=randint(20,1,2)
m =
   1
   0
   1
   0
   1
   1
   0
   0
   1
   0
要得到
m=
    1
    1
    0
    0
    1
    0
    0
    0
    1
    1
也就是当前位与下一位异或得到当前位,该怎么编码?

simon21 发表于 2007-4-27 15:57

clear all;
sym=
I0=input('Please input the I1? ')%差分编码%
Q0=input('Please input the Q1? ')
I=[];
Q=[];
=size(sym);
for add=1:m   
    A=sym(add,1);B=sym(add,2);
    if add==1
       IK(add)=((~(xor(A,B))))&(xor(A,I0))|(xor(A,B))&(xor(A,Q0));
       QK(add)=((~(xor(A,B))))&(xor(B,Q0))|(xor(A,B))&(xor(B,I0));
       sym(add,1)=IK(add);
       sym(add,2)=QK(add);
    else
    IK(add)=((~(xor(A,B))))&(xor(A,IK(add-1)))|(xor(A,B))&(xor(A,QK(add-1)));
    QK(add)=((~(xor(A,B))))&(xor(B,QK(add-1)))|(xor(A,B))&(xor(B,IK(add-1)));
    sym(add,1)=IK(add) ;
    sym(add,2)=QK(add);
    end
end
sym
I=[];
Q=[];
for add=1:m    %差分解码%
I(add)=sym(add,1);Q(add)=sym(add,2);
if add==1
   A1=(~Q(add)&~I0&Q0)|(I0&Q0&~I(add))|(I0&~Q0&Q(add))|(~I0&~Q0&I(add));
   B1=(I(add)&~I0&Q0)|(I0&Q0&~Q(add))|(I0&~Q0&~I(add))|(~I0&~Q0&Q(add));
    sym(add,1)=A1;sym(add,2)=B1;
else
      AK=(~Q(add)&~I(add-1)&Q(add-1))|(I(add-1)&Q(add-1)&~I(add))|(I(add-1)&~Q(add-1)&Q(add))|(~I(add-1)&~Q(add-1)&I(add));
   BK=(I(add)&~I(add-1)&Q(add-1))|(I(add-1)&Q(add-1)&~Q(add))|(I(add-1)&~Q(add-1)&~I(add))|(~I(add-1)&~Q(add-1)&Q(add));
    sym(add,1)=AK;sym(add,2)=BK;
    end
end
sym

是不是这个东西?
页: [1]
查看完整版本: 怎么实现差分编码?