/elen7052/bpsk.m
http://spreadspectrum.googlecode.com/ · MATLAB · 23 lines · 21 code · 2 blank · 0 comment · 2 complexity · 9d98ad9c6de755a8f39b14a127e6b120 MD5 · raw file
- function msg = bpsk(x,fc)
-
- onebit=101; %number of samples per bit
- n=(length(x))/onebit; %number of bits transmitted
- b=onebit;
- c=1;
- msg=[];
-
- for m=1:n; %iteration from 1 to number of bits
- y=x(c:b); % take the needed signal for one bit
- f=cos(2*pi*fc*(0:100));%reference signal for Quadrature
- g=cos(2*pi*fc*(0:100)+pi);%reference signal for Inphase
- a=y.*f; % (received signal) . (reference signal for Quadrature)
- d=y.*g; % (received signal) . (reference signal for Inphase)
- t= sum(a)-sum(d); %constellation
- if t>0;
- msg = [msg 1]; %accumulate the value of output into msg
- else
- msg = [msg -1]; %accumulate the value of output into msg
- end
- b=b+onebit; %update the value of b for the next input
- c=c+onebit; %update the value of c for the next input
- end