?? gold_codes.m
字號:
clear
clc
G=31; % Code length
K=10; % Number of Codes or code sequences
%.................Generation of first perferred PN sequence................
sd1 =randsrc(1,5,[0 1]);
PN1=[];
for j=1:G
PN1=[PN1 sd1(1)];
if sd1(1)==sd1(4)
temp1=0;
else temp1=1;
end
sd1(1)=sd1(2);
sd1(2)=sd1(3);
sd1(3)=sd1(4);
sd1(4)=sd1(5);
sd1(5)=temp1;
end
%..........................................................................
%.................Generation of Second perferred PN sequence...............
sd2 =randsrc(1,5,[0 1]);
PN2=[];
for j=1:G
PN2=[PN2 sd2(1)];
if sd2(1)==sd2(2)
temp1=0;
else temp1=1;
end
if sd2(4)==temp1
temp2=0;
else temp2=1;
end
if sd2(5)==temp2
temp3=0;
else temp3=1;
end
sd2(1)=sd2(2);
sd2(2)=sd2(3);
sd2(3)=sd2(4);
sd2(4)=sd2(5);
sd2(5)=temp3;
end
%..........................................................................
%.........................Generation of Gold Codes.........................
Co_Mat=[];
code=[];
PN2(31)=PN2(1);
for k=1:G-1
PN2(k)=PN2(k+1);
end
for j=1:G
code=[code xor(PN1(j),PN2(j))];
end
Co_Mat=[Co_Mat code'];
end
for row=1:G
for col=1:K
if Co_Mat(row,col)==0
Co_Mat(row,col)=-1;
end
end
end
%..........................................................................
%....................Chechking corelation performance......................
A=[]; AA=0;B=[];
for j=1:K
for i=1:K
for k=1:G
AA=AA+Co_Mat(k,j)*Co_Mat(k,i);
end
A=[A AA];
AA=0;
end
B=[B A'];
B=[B A']
A=[];
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -