%% ECE 146B-Lab 2-4PAM MAP

% Problem 2c: input 2 0/1 bits, output a symbol taking one of four values 
% in {±1,±3}.

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

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

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