⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 untitled2.m

📁 i was not knowing matlab in depth so i have sent simple basic programs
💻 M
字号:
%..........................................................................
% This Program generates 10 Gold code sequences, each 31 bits long. These
% codes are outputted as coloumns of matrix Co_Mat.
% Programed by Imran Ali (Mehran University, Jamshoro, Sindh, Pakistan)
%..........................................................................
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]);      % First user's seed.
PN1=[];                         % Spreading code vector of user-1
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=[];
for codes=1:K
    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'];
    A=[];
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -