📄 rayleigh_ch.m
字号:
function CH=Rayleigh_CH(t0,fs,fc,V,maxPNum,pNum,pGain,sPath,Len,fr)
% function CH=Rayleigh_CH(t0,fs,fc,V,maxPNum,pNum,pGain,sPath,Len,fr)
% usage: CH=Rayleigh_CH(0,5e6,2e9,30e3/3600,1,1,1,1,1000,1)
% This function is used to calculate the impulse response
% of a multipath Rayleigh fading channel.
% Parameters:
% Output:
% CH : Channel response.
% Input:
% pGain: Gain for different paths.
% t0: Initial time offset.
% fs: Sampling frequency.
% fc: Carrier frequency.
% V : Velocity of a vehicle.
% maxPNum: Maxmum number of paths.
% pNum: Actual number of paths needed.
% sPath: Paths holded in a vector to be selected.
% Notice that it begins from integer 1.
% Len: Length of response sampled along the time axis.
% fr:is the number of frame changing the start time
%% Initialization:
% The wavelength of the carrier.
lemta=3.e+8/fc;
% The Doppler frequency.
Wm=2*pi*V/lemta;
% Some parameters.
N0=maxPNum;
N =(2*N0+1)*2;
% Resetting of the in-phase and Q-phase channel response.
Xi=zeros(pNum,Len);
Xq=zeros(pNum,Len);
indice=1;
for i=1:maxPNum
if i==sPath(1,indice)
% Set beta and sita.
beta=zeros(1,N0);
sita=zeros(1,N0);
for i1=1:N0
beta(1,i1)=pi*i1/(N0+1);
sita(1,i1)=beta(1,i1)+2*pi*(i-1)/(N0+1);
end
for i1=1:Len
% Calculate cosine for different i2.
csin=zeros(1,N0);
for i2=1:N0
csin(1,i2)=cos(Wm*cos(2*pi*i2/N)*(i1/fs+t0+fr*(1.5e-5))+sita(1,i2));
end
% Channel response.
Xi(indice,i1)=2*cos(beta)*csin'+1.414*cos(Wm*(i1/fs+t0+fr*(1.5e-5)));
Xq(indice,i1)=2*sin(beta)*csin';
end
indice=indice+1;
end
end
%
Ch=1.414/N^0.5*(Xi+j*Xq);
%Gain evaluation:
CH=(Ch'*diag(pGain))';
info1=round(rand(1,24576));
info1=2*info1-1;
ch1=CH(1,:);
ch1=info1.*ch1;
ch1=abs(ch1);
ch1_m=sqrt(mean(ch1.*ch1));
ch1=ch1/ch1_m;
info2(1:1000)=0;
info2(1001:24576)=info1(1001:24576)
ch2=CH(1,:).*info1+CH(2,:).*info2;
ch2=abs(ch2);
ch2_m=sqrt(mean(ch2.*ch2));
ch2=ch2/ch2_m;
xx=[1:1:24576];
plot(xx,ch1,'--b',xx,ch2,'--g');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -