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

📄 mpathchannel.m

📁 用matlab程序实现WCDMA系统的仿真
💻 M
字号:
function y=MpathChannel(SigLast,SigCurrent,SigNext,delays,amplitudes,TxPulseLength,SamplesPerChip)
%************************************************************************
%function y=MpathChannel(SigLast,SigCurrent,SigNext,delays,amplitudes,TxPulseLength,SamplesPerChip)
%
% Copyright 2002 The Mobile and Portable Radio Research Group
%
%This function simulates the behavior of a specular multhipath channel 
%on the signal associated with the current frame (SigCurrent).  The other 
%two signals SigLast (the signal associated with the previous frame) and
%SigNext (the signal associated with the future frame) are included so 
%that ther signal points can be included as needed when the delays are 
%incorporated.  They are also included to ensure that fading envelop, which
%is computed via interpolation, remains continuous from frame to frame.
%
%The number of multipath components is equal to the length of the vector,
%"delay".  For each multipath component, SigCurrent is shifted by the 
%amount specified in delay.  SigLast is then used to fill the front 
%part of the shifted version of SigCurrent, and SigNext is used to fill 
%the rear of the shifted version of SigCurrent.  This replica is then 
%scaled by an fading signal.  The fading signal is generated by taking
%the appropriate column in "amplitude" (the i^th column corresponds to 
%the i^th multipath component) and inpterpolating that column in order 
%to generate a fading vector whose length is equal to the replica.  
%
%Once each replica is generated and the fading applied, they are then
%summed together to create the channel output.
%
%Parameters
%   Input
%      SigLast          vector   Contains the transmitted signal associated
%                                with the previous WCDMA radio frame
%      SigCurrent       vector   Contains the transmitted signal associated
%                                with the currentWCDMA radio frame
%      SigNext          vector   Contains the transmitted signal associated
%                                with the next WCDMA radio frame
%      delays           vector   Contains the delays (in discrete time) of
%                                multipath channel.  Its length determines
%                                the number of multipath components
%      amplitudes       matrix   Contains the fading signal associated with 
%                       or       each delay.  There is a one-to-one 
%                       vector   correspondence between the i^th element of 
%                                "delay" and the i^th column of "amplitudes"
%                                 Each column contains 60 elements.  The first
%                                 20 corresponds to the fading in "SigLast",
%                                 the next 20 corresponds to the fading in 
%                                 "SigCurrent", and the final 20 are associated
%                                 with "SigNext".
%      TxPulseLength    Scalar   Length of the transmitter filter pulse
%      SamplesPerChip   Scalar   Number of samples per chip
%   Output
%      y                vector   Distorted version of the transmitted signal
%                                due to the multipath.
%************************************************************************
NumDelays=length(delays); %Number of Multipath Components
MaxDelay=max(delays);     %Maximum Delay in the channel
FrameSampleLength=38400*SamplesPerChip; %Number of Samples for each frame duration
SigLength=length(SigCurrent);  %Number of Samples for each signal associated frame
                               %This does not equal "FrameSampleLength" because 
                               %"SigCurrent" contains the entire pulse contribution
                               %for each chip in the frame.  Since the pulse shaping
                               %filter length is more than one chip duration,
                               %SigLength is typically longer
FrameBegin=(TxPulseLength+1)/2; %The index associated with the maximum value of the 
                                %pulse associated with the first chip in the frame                               
FrameEnd=FrameBegin+SamplesPerChip*38400-1; %The index associated with the maximum
                                            %value of the pulse associated with the 
                                            %last chip in the frame
%Initialize Output Vector
%The output vector must be long enough to support the "SigCurrent" when shifted by
%the maximum delay in the channel, "MaxDelay"
y=zeros(1,length(SigCurrent)+MaxDelay);

%Error Checking for "ampliutdes"
[nrow,ncol]=size(amplitudes);
if nrow ~= 60
   error(' "amplitudes" must have 60 rows');
end
if ncol ~= NumDelays
   error ('The number of columns in  "amplitudes" must equal the length of "delays"')
end

%Determine the original abcissa values for the fading signal in "amplidues"  
%Note that in amplutides, we have 20 samples of the fading signal per
%frame duration.  Accordingly, we need to compute the abcissa values
%from 0 to FrameSampleLength-1 for one group of 20 signals.  The abcissa
%values will be uniformly distributed across the frame duration
increment=FrameSampleLength/20;
x=0:increment:(FrameSampleLength-1);

for k=1:NumDelays
   %Determine the number of fading Coefficient Data Points we need from the last frame
   %At least two coefficients are needed because they will be interpolated to obtain 
   %a fading coefficient for each sample point.  Further, a staged interpolation that 
   %initially involves cubic or cubic spline interpolation will be used.  Therefore, to 
   %ensure that fading signal remains continuous from frame to frame (i.e., interation-to-
   %iteration) it is necessary to include 2 coefficients from the previous frame, especially
   %when cubic interpolation is employed
   %
   %This determines the number of fading coefficients that we needed from the last frame
   PriorInterpPoints=fix(delays(k)/increment)+2;
   %This extracts the indicies associated with the fading coefficients from the last frame
   PriorAbcissa=20-PriorInterpPoints+1:20;
   %This extracts frame sample positions associated with each coefficient
   PriorIndex=x(PriorAbcissa);
   %Get the appropriate Fading Coefficients associated with the previous frame
   FadeLast=amplitudes(PriorAbcissa,k).';
   %Determine the indicies of the signal points in the last frame that need to be included
   %in order to ensure continuity in the interpolated fading signal and the associated 
   %faded signal on a frame-to-frame basis
   PriorInterpIndex=ceil(x(20-PriorInterpPoints+1)):(FrameSampleLength-1);
   %Get those signal points
   PriorSig=SigLast(FrameBegin+PriorInterpIndex);
   
   %Determine the number of fading Coefficient Data Points we need from the next frame
   %At least two coefficients are needed because they will be interpolated to obtain 
   %a fading coefficient for each sample point.  Further, a staged interpolation that 
   %initially involves cubic or cubic spline interpolation will be used.  Therefore, to 
   %ensure that fading signal remains continuous from frame to frame (i.e., interation-to-
   %iteration) it is necessary to include 2 coefficients from the next frame, especially
   %when cubic interpolation is employed
   %
   %This determines the number of fading coefficients that we needed from the next frame
   PostInterpPoints=ceil((MaxDelay-delays(k))/increment)+2;
   %This extracts the indicies associated with the fading coefficients from the next frame
   PostAbcissa=1:PostInterpPoints;
   %This extracts the frame sample positions associated with each coeficient
   PostIndex=x(PostAbcissa);
   %Get the fading coefficients associated with the next frame
   FadeNext=amplitudes(40+PostAbcissa,k).';
   %Determin the indicies (Offset from "FrameBegin") of the signal points in the next frame
   %that need to be included in order to ensure continuity in the interpolated fading 
   %signal and the associated fadied signal on a frame-to-frame basis
   PostInterpIndex=0:x(PostInterpPoints);
   %Get the signal points
   PostSig=SigNext(FrameBegin+PostInterpIndex);
   
   %Combine "PriorSig" with "PostSig" and the appropriate portion of "SigCurrent"
   %The appropriate portion of "SigCurrent" is determined by "SigIndex"
   SigIndex=FrameBegin+(0:FrameSampleLength-1);
   %MComponent=[PriorSig,SigCurrent(SigIndex),PostSig];
   MComponent=[PriorSig,SigCurrent(FrameBegin:(FrameBegin+FrameSampleLength-1)),PostSig];
   %Compute abcissa for the data to be interpolated
   xd=[PriorIndex-FrameSampleLength,x(1:20),FrameSampleLength+PostIndex];
   %Concatenate the fading vector
   FadeD=[FadeLast, amplitudes(21:40,k).', FadeNext];
   %Create tne inperolated abcissa
   xi=ceil(min(xd)):floor(max(xd));
   index=(2-xi(1)-delays(k)-FrameBegin: 1-xi(1)-delays(k)-FrameBegin+length(y));
   %Conduct Interpolation
   %Fade=interp1(xd,FadeD,xi(index),'*cubic');
   Fade=WCDMACubicInterp(xd,FadeD,xi(index)).';
   %scale signal with fading signal at the appropriate abcissa points
   %to create the multipath component
   FadedMComponent=Fade.*MComponent(index);
   %Combine multipath components
   y=y+FadedMComponent;
end
         
         
   

⌨️ 快捷键说明

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