📄 mai.m
字号:
function [y,NextSignal]=mai(CurrentSignal,LastSignal,ChanCode,MPathDelay,MPathAmp,fDoppler,SamplesPerChip,PulseShape,MaxOffset)
%*********************************************************************************************
% y=mai(NumInterferers,ChanCode,MPathDelay,MPathAmp,SamplesPerChip,PulseShape,MaxOffset)
%
% Copyright 2002 The Mobile and Portable Radio Research Group
%
%This function generates the mutual access interference (MAI) for one frame. Each interferer
%has an offset which is equal to an integer multiple of the sampling period. This offset
%will not exceed MaxOffset, which is defined in terms of chips. For each interferer,
%the data and control bits are generated at random, spread with the channel code and
%then scambled with a different code per interferer. The resulting frame is the pulse shaped
%and processed through the channel defined by MPathDelay and MPathAmp. Once this is
%is done for each interferer, the signals are then added to create the MAI signal
%
%Parameters
% Input
% NumInterferers Scalar The number of interfering signals
% ChanCode Matrix The channel code matrix. For simplicity each interferer
% will have the same channel code. Further, each interferer
% will only have one DPDCH. Multiple DPDCHs per interferer
% will be added at a later time
% MPathDelay Vector The multipath delays in terms of number of samples
% For simplicity, each interferer will have the same
% multipath fading profile
% MPathAmp Vector The average energy for each multipath delay
% SamplesPerChip Scalar The number of samples per chip
% PulseShape Vector The pulse shaping filter impulse response used for the system
% MaxOffset Scalar The maximum allowable offset for each interferer in terms of
% chips.
% Output
% y Vector The mutual access interference (MAI) signal
%
%*********************************************************************************************
ChipsPerFrame=38400;
SigLength=length(CurrentSignal);
MaxDelay=max(MPathDelay);
y=zeros(1,SigLength+MaxDelay);
[NumInterferers,col]=size(CurrentSignal);
for k=1:NumInterferers
%*****************************
% DEBUG CODE -- MUST BE REMOVED
rand('state',0);
% DEBUG CODE -- MUST BE REMOVED
%*****************************
SF=size(ChanCode,1);
%Random Generation of Control Bits
%The specific sequence should not be that important
ControlBits=sign(rand(1,150)-0.5);
%Generate Scramble Sequence
ScrambleCodeNumber = round((2^24-1)*rand(1));
ScrambleCode=scramble_long(ScrambleCodeNumber);
%********************
%Debugging Purposes Only
% if k==1
fee=[ControlBits.';ScrambleCodeNumber];
save testdat.txt fee -ascii
% end
%Debugging Purposes Only
%********************
%Generate uplink Frame for interferer
UplinkFrame=gen_uplink_wcdma_frame(1,ScrambleCode.',ChanCode,ControlBits,1,1);
NextSignal(k,:)=GenWCDMAUplinkSignal(UplinkFrame,UplinkFrame,UplinkFrame,PulseShape,SamplesPerChip);
%incorporate offset
offset=round(SamplesPerChip*MaxOffset*2*(rand(1,1)-0.5));
%***********************************
%DEBUG CODE
offset = 10;
%DEBUG CODE
%***********************************
if offset > MaxDelay
MAIUplinkSignal=[LastSignal(k,(SigLength-offset+1):SigLength),CurrentSignal(k,1:(SigLength+MaxDelay-offset))];
elseif offset >= 1
MAIUplinkSignal=[LastSignal(k,(SigLength-offset+1):SigLength),CurrentSignal(k,1:(SigLength)),NextSignal(k,1:(MaxDelay-offset))];
elseif offset < 0
MAIUplinkSignal=[CurrentSignal(k,1-offset:SigLength),NextSignal(1:MaxDelay-offset)];
else
MAIUplinkSignal=[CurrentSignal(k,:),NextSignal(k,1:MaxDelay)];
end
%Apply Multipath Channel
MPathSignal=MaiMpathChannel(MAIUplinkSignal,MPathDelay,MPathAmp,fDoppler,SamplesPerChip);
y=y+MPathSignal;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -