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

📄 gen_uplink_wcdma_frame.m

📁 用matlab程序实现WCDMA系统的仿真
💻 M
字号:
function [y,z]=gen_uplink_WCDMA_frame(N,scramble_code,chan_code,DPCCH_code,beta_c,beta_d)
%*************************************************************************
%function [y z]=gen_uplink_WCDMA_frame(N,scramble_code,chan_code,DPCCH_code,beta_c,beta_d)
% Copyright 2002 The Mobile and Portable Radio Research Group
%
%
%Generates the exactly one complex frame of the Dedicated Physical
%Data Channel/Dedicated Physical Control Channel (DPDCH/DPCCH) prior to 
%transmission into the channel.  Specifically, this function
%     1.  Generates the data for each of the N data channels (DPDCH)
%     2.  Generates the data for the control channel (DPCCH)
%     3.  Applies the channel code
%     4.  Combines the N data channels and the one control channel
%         into a complex data stream
%     5.  Applies the srambling code
%
%Parameters
%   Input
%      N               Scalar    # of data channels (DPDCH).
%                                Must be between 1 and 6
%      scramble_code   Vector    complex scramble code generated by
%                                "scramble_long" or "scramble_short"
%      chan_code       Matrix    Channel code matrix.  If N>1, then
%                                "chan_code" must be a 4x4 matrix
%      DPCCH_code      Scalar    The data in the control channel (DPCCH)
%      beta_c          Scalar    Gain factor for DPCCH (between 0 and 1)
%      beta_d          Scalar    Gain factor for DPDCH (between 0 and 1)
%
%   Output
%      y               Vector    Complex frame for radio uplink
%      z               Vector    Data used to generate complex frame 
%
%***************************************************************************

chips_per_frame=38400;

%Only 6 data channels are allowed
if (N<1)|(N>6), error('N must be between 1 and 6'); end

%For the case where N>1, check to see if chan_code is a 4x4 matrix
[nrow,ncol]=size(chan_code);
if N>1
   if nrow~=4
      error(['SF=',int2str(nrow),', N=',int2str(N),'!  spreading factor must equal 4 if N>1']); 
   end      
end

%At least one of the weights must be equal to 1
if ((beta_c~=1) & (beta_d~=1))
   error('At least one of the two weight terms must be equal to 1');
end

%All weights must fall on the closed unit interval
if (beta_c<0) | (beta_c>1), error('beta_c must be between 0 and 1'); end
if (beta_d<0) | (beta_d>1), error('beta_d must be between 0 and 1'); end

%Determine spreading factor
SF=nrow;

%Generate data channels prior to spreading
Ndata_per_frame=chips_per_frame/SF;
%***********************
%Commented out for Debug Purposes
data_bits=sign(rand(N,Ndata_per_frame)-0.5);
%Commented out for Debug Purposes

z=data_bits;

%Apply Orthogonal Channelizatoin Codes to data
if N>1
   kk=[1 1 3 3 2 2]+1;
   for k=1:N
      channelized_data(k,:)=reshape(chan_code(kk(k),:).'*data_bits(k,:),1,chips_per_frame);
   end
else
   k=(SF/4)+1;
   channelized_data=reshape(chan_code(k,:).'*data_bits,1,chips_per_frame);
end

clear data_bits

%Apply Channelation code to control data
control_data=reshape(ones(256,1)*DPCCH_code,1,chips_per_frame);

%Create Complex Data Stream
if N==1, complex_data=channelized_data+j*control_data;
else
   complex_data=sum(channelized_data(1:2:N,:),1)+j*(control_data+sum(channelized_data(2:2:N,:),1));
end
clear channelized_data control_data
%Scramble_data
y=complex_data.*double(scramble_code);
clear complex_data
%save temp complex_data channelized_data

⌨️ 快捷键说明

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