%% ECE 146B-Lab 2-QPSK MAP

% Problem 2b: input 2 0/1 bits, output a symbol taking one of four values
%in ±1 ± j.

%Bitseq must be even length
function output=qpskmap(bitseq)

oddseq=bitseq(1:2:length(bitseq));
evenseq=bitseq(2:2:length(bitseq));

% 00 = 1+j, 01 = 1-j, 10 = -1+j, 11 = -1-j
output=[(~oddseq & ~evenseq)*(1+1j)+(~oddseq & evenseq)*(1-1j)+...
        (oddseq & ~evenseq)*(-1+1j)+(oddseq & evenseq)*(-1-1j)];
