www.pudn.com > WCDMA.rar > ovsf_code.m


function y=ovsf_code(SF) 
%*********************************************************************** 
%function y=ovsf_code(SF) 
% 
% Copyright 2002 The Mobile and Portable Radio Research Group 
% 
%Computes the channelization codes used for the WCDMA UTRA system.  The 
%code generation algorithm is defined in ETSI TS 123 213 V3.2.1 
% 
% Parameters 
%   Input 
%    SF   scalar  Spreading factor (must be a power of 2) 
% 
%   Output 
%    y    matrix  Matrix of channelization codes 
% 
%*********************************************************************** 
 
N=log2(SF); 
 
%If SF is not a power of 2 then N will not be an integer 
if rem(N,1)~=0,error(['SF = ',int2str(SF),': SF must be a power of 2']) 
end 
 
%If N is an integer, then we can continue 
if SF==1, y=1; return; end 
 
y=1;  %Initialize code for a spreading factor of 1 
for k=1:N 
   foo=[]; 
   for m=2:2:pow2(k) 
      fee=y(m/2,:); 
      foo=[foo;fee fee;fee -fee]; 
   end 
   y=foo; 
end