I forget what the solution was but I made a new scrambler which works code below:
if true
% code
% Scrambler: used to prevent spectral lines from forming in bit
% Sequence. [0 0 1 1] LFSR
function scrambled=scrambler(data)
% Initialize variables:
scrambled=[];
count=1;
% Set r1 and r2 initial values:
r1=0;r2=0;
% Cycle the data through the registers:
for i=1:length(data) % all the data 1 circulation through LFSR
% First two registers Pass all the data:
if (count==1)
r1=data(i);
result=r1;
end
if (count==2)
r2=data(i);
result=r2;
end
% Last two registers scramble data by xoring them
% with value of first two registers:
if (count==3)
r3=data(i);
result=xor(r3,r1);
end
if (count==4)
r4=data(i);
result=xor(r4,r2);
end
% Fill data in accumulator array:
scrambled=[scrambled result];
% Reset Counter:
if (count==4)
count=1;
else
count=count+1;
end
end
end
