% Theoretical output for comparison with gpstk acquisition program. G1 = [1,1,1,1,1,1,1,1,1,1]; G2 = [1,1,1,1,1,1,1,1,1,1]; PRN = zeros(1,2046); count = 1; while count <= 2046 newBit1 = xor(G1(3),G1(10)); newBit2 = xor(G2(2),G2(3)); newBit2 = xor(newBit2,G2(6)); newBit2 = xor(newBit2,G2(8)); newBit2 = xor(newBit2,G2(9)); newBit2 = xor(newBit2,G2(10)); G2i = xor(G2(5),G2(9)); PRN(count) = xor(G2i,G1(10)); G1 = [newBit1 G1(1:9)]; G2 = [newBit2 G2(1:9)]; count = count + 1; end PRNtwo = (PRN == 0)*(1)+(PRN==1)*(-1); %changed to -1 and 1 from binary x1 = PRNtwo([(end-173:end) (1:end-173)]); for n = 1:1023 sum = 0; for k = 1:1023 sum = sum + PRNtwo(k) * x1(k+n); end RX(n) = (abs(sum)/1023)*130; %/1023; % divide to get normalized graph end n = 1:1023; plot(n,RX,'r');