OutputPort1=InputPort1;
OutputPort2=InputPort1;

%Find lengths of vectors

sampledLength = length(InputPort1.Sampled.Signal);
seqLength = length(InputPort2.Sequence);

%Repeat elements of bit sequence so vectors match


samplesPerBit = floor(sampledLength/seqLength);
padding = mod(sampledLength,seqLength);
seqMatched=repmat(InputPort2.Sequence',1,samplesPerBit)';
seqMatched=seqMatched(:)';
seqMatched= [seqMatched zeros(1,padding);];

%Find complement of sequence
compseqMatched = ~seqMatched;

ai = kron(seqMatched(1:2:end),ones(size(seqMatched(1:2:end))));
aq = kron(seqMatched(2:2:end),ones(size(seqMatched(1:2:end))));
ai = [ai zeros(1,padding);  ]; % padding with zero to make the matrix dimension match 
aq = [zeros(1,padding); aq ];  % adding delay of T for Q-arm
        
%Multiply vectors to produce the outputs
OutputPort1.Sampled.Signal = InputPort1.Sampled.Signal.*seqMatched;
OutputPort2.Sampled.Signal = InputPort1.Sampled.Signal.*compseqMatched;

