/elen7052/bpsk.m

http://spreadspectrum.googlecode.com/ · MATLAB · 23 lines · 21 code · 2 blank · 0 comment · 2 complexity · 9d98ad9c6de755a8f39b14a127e6b120 MD5 · raw file

  1. function msg = bpsk(x,fc)
  2. onebit=101; %number of samples per bit
  3. n=(length(x))/onebit; %number of bits transmitted
  4. b=onebit;
  5. c=1;
  6. msg=[];
  7. for m=1:n; %iteration from 1 to number of bits
  8. y=x(c:b); % take the needed signal for one bit
  9. f=cos(2*pi*fc*(0:100));%reference signal for Quadrature
  10. g=cos(2*pi*fc*(0:100)+pi);%reference signal for Inphase
  11. a=y.*f; % (received signal) . (reference signal for Quadrature)
  12. d=y.*g; % (received signal) . (reference signal for Inphase)
  13. t= sum(a)-sum(d); %constellation
  14. if t>0;
  15. msg = [msg 1]; %accumulate the value of output into msg
  16. else
  17. msg = [msg -1]; %accumulate the value of output into msg
  18. end
  19. b=b+onebit; %update the value of b for the next input
  20. c=c+onebit; %update the value of c for the next input
  21. end