Cm_dpske.m
Upload User: loeagle
Upload Date: 2013-03-02
Package Size: 1236k
Code Size: 1k
Development Platform:

Matlab

  1. function [enc_comp] = cm_dpske(E,M,mapping,sequence);
  2. % [enc_comp] = cm_dpske(E,M,mapping,sequence)
  3. %  CM_DPSKE differentially encodes a sequence.
  4. %  E is the average energy, M is the number of constellation points,
  5. %  and mapping is the vector defining how the constellation points are 
  6. %  allocated. Finally, ``sequence'' is the uncoded binary data sequence. 
  7. k=log2(M);
  8. N=length(sequence);
  9. % If N is not divisible by k, append zeros, so that it is...
  10. remainder=rem(N,k);
  11. if (remainder~=0),
  12.   for i=N+1:N+k-remainder,
  13.     sequence(i)=0;
  14.   end;
  15.   N=N+k-remainder;
  16. end;
  17. theta=0; % Initially, assume that theta=0.
  18. for i=1:k:N,
  19.   index=0;
  20.   for j=i:i+k-1,
  21.     index=2*index+sequence(j);
  22.   end;
  23.   index=index+1;
  24.   theta=mod(2*pi*mapping(index)/M+theta,2*pi);
  25.   enc_comp((i+k-1)/k,1)=sqrt(E)*cos(theta);
  26.   enc_comp((i+k-1)/k,2)=sqrt(E)*sin(theta);
  27. end;