?? cdma_codes產(chǎn)生擴(kuò)頻碼隨機(jī)、h、.m
字號:
%cdma_codes.m create a matrix of spreading codes
%產(chǎn)生擴(kuò)頻碼
%returns C : L X K matrix of spreading codes
%
%
%given L : spreading gain擴(kuò)頻增益
% K_in : in-cell users蜂窩內(nèi)的用戶%
% K_out : out-of-cell users蜂窩外的用戶
% code_type : 0 = random 1 = hadamard
% 2 = gold 碼型選擇0隨機(jī)、1哈德馬德、2GOLD碼
% code_seed : seed for random gen of codes
function [C]=cdma_codes(K_in,K_out,code_type,L,code_seed)
K=K_in+K_out;
c=zeros(L,K);
switch code_type
case 0, %random
rand('state',code_seed);
c=2*round(rand(L,K))-1;
case 1, %hadamard
if rem(L,4)
error('Spreading gain must be modulo 4 for hadamard codes');
else
codes=hadamard(L);
if K_in<=L
c=codes(:,1:K_in);
else
for i=1:floor(K_in/L)
c(:,(i-1)*L+1:i*L)=codes(:,1:L)
end;
c(:,floor(K_in/L)*L+1:K_in)=codes(:,1:K_in-floor(K_in/L)*L);
end;
rand('state',code_seed); %ditribution of out-cell
c=[c codes(:,ceil(L*rand(1,K_out)))];
end;
case 2, %gold
if L<=127
codes=goldlow(L,K_in+K_out);
else
n=log2(L+1);
codes=gold(n,L);
end;
if K_in<=L
c=codes(:,1:K_in);
else
for i=1:floor(K_in/L)
c(:,(i-1)*L+1:i*L)=codes(:,1:L)
end;
c(:,floor(K_in/L)*L+1:K_in)=codes(:,1:K_in-floor(K_in/L)*L);
end;
rand('state',code_seed); %ditribution of out-cell
c=[c codes(:,ceil(L*rand(1,K_out)))];
otherwise
error(['Code_type ', num2str(code_type),' is invalid']);
end;
for i=1:K %normalize the codes
C(:,i)=c(:,i);%/norm(c(:,i));
end
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -